Mercurial > hg > orthanc-stone
diff Resources/CMake/Utilities.cmake @ 520:7a16fb9a4ba5 am-touch-events
merge bgo-commands-codegen
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Tue, 12 Mar 2019 14:50:14 +0100 |
parents | 5055031f4a06 |
children | dc5acb03ad93 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/CMake/Utilities.cmake Tue Mar 12 14:50:14 2019 +0100 @@ -0,0 +1,37 @@ + + +macro(GetFilenameFromPath TargetVariable Path) +#message(STATUS "GetFilenameFromPath (1): Path = ${Path} TargetVariable = ${${TargetVariable}}") +string(REPLACE "\\" "/" PathWithFwdSlashes "${Path}") +string(REGEX REPLACE "^.*/" "" ${TargetVariable} "${PathWithFwdSlashes}") +#message(STATUS "GetFilenameFromPath (2): Path = ${Path} Path = ${PathWithFwdSlashes} TargetVariable = ${TargetVariable}") +endmacro() + +macro(GetFilePathWithoutLastExtension TargetVariable FilePath) +string(REGEX REPLACE "(^.*)\\.([^\\.]+)" "\\1" ${TargetVariable} "${FilePath}") +#message(STATUS "GetFileNameWithoutLastExtension: FilePath = ${FilePath} TargetVariable = ${${TargetVariable}}") +endmacro() + +macro(Test_GetFilePathWithoutLastExtension) +set(tmp "/prout/zi/goui.goui.cpp") +GetFilePathWithoutLastExtension(TargetVariable "${tmp}") +if(NOT ("${TargetVariable}" STREQUAL "/prout/zi/goui.goui")) + message(FATAL_ERROR "Test_GetFilePathWithoutLastExtension failed (1)") +else() + #message(STATUS "Test_GetFilePathWithoutLastExtension: <<OK>>") +endif() +endmacro() + +Test_GetFilePathWithoutLastExtension() + +macro(Test_GetFilenameFromPath) +set(tmp "/prout/../../dada/zi/goui.goui.cpp") +GetFilenameFromPath(TargetVariable "${tmp}") +if(NOT ("${TargetVariable}" STREQUAL "goui.goui.cpp")) + message(FATAL_ERROR "Test_GetFilenameFromPath failed") +else() + #message(STATUS "Test_GetFilenameFromPath: <<OK>>") +endif() +endmacro() + +Test_GetFilenameFromPath()