diff --git a/CMake/SlicerCPack.cmake b/CMake/SlicerCPack.cmake index 9c958c32de4ae04ddc433a1347c42d3997dd9400..29d5ddf27134ff1b2e77d662728a4c7295cdb7ca 100644 --- a/CMake/SlicerCPack.cmake +++ b/CMake/SlicerCPack.cmake @@ -10,7 +10,7 @@ endif() set(SlicerBlockInstallQtPlugins_subdirectories imageformats sqldrivers) include(${Slicer_CMAKE_DIR}/SlicerBlockInstallQtPlugins.cmake) -if(Slicer_BUILD_DICOM_SUPPORT) +if(${PROJECT_NAME}_BUILD_DICOM_SUPPORT) include(${Slicer_CMAKE_DIR}/SlicerBlockInstallDCMTKApps.cmake) endif() diff --git a/CMake/SlicerMacroCheckExternalProjectDependency.cmake b/CMake/SlicerMacroCheckExternalProjectDependency.cmake index 3ad4b1e4ca163ee80cf9f5638703af8aa9f221a7..fa92e51aeb1e1909386c856d56bc44093823fe4b 100644 --- a/CMake/SlicerMacroCheckExternalProjectDependency.cmake +++ b/CMake/SlicerMacroCheckExternalProjectDependency.cmake @@ -22,6 +22,18 @@ if(NOT EXISTS "${EXTERNAL_PROJECT_DIR}") set(EXTERNAL_PROJECT_DIR ${${CMAKE_PROJECT_NAME}_SOURCE_DIR}/SuperBuild) endif() +### +macro(ProjectDependancyPush CACHE_LIST VALUE) + list(APPEND ${CACHE_LIST} ${VALUE}) + #message(STATUS "PUSHING ${VALUE} onto ${CACHE_LIST}: --> ${${CACHE_LIST}}") +endmacro() + +macro(ProjectDependancyPop CACHE_LIST TVAR) + list(GET ${CACHE_LIST} -1 ${TVAR}) + list(REMOVE_AT ${CACHE_LIST} -1) + #message(STATUS "POPING ${${TVAR}} from ${CACHE_LIST}: --> ${${CACHE_LIST}}") +endmacro() + macro(SlicerMacroCheckExternalProjectDependency proj) # Set indent variable if needed if(NOT DEFINED __indent) diff --git a/SuperBuild.cmake b/SuperBuild.cmake index 406799e3f29f9336c200783fdfe1e93b20a940d5..dbf05115cf69a356cd3e9227065d2c9c2ca1644e 100644 --- a/SuperBuild.cmake +++ b/SuperBuild.cmake @@ -65,11 +65,11 @@ include(SlicerMacroCheckExternalProjectDependency) # With CMake 2.8.9 or later, the UPDATE_COMMAND is required for updates to occur. # For earlier versions, we nullify the update state to prevent updates and # undesirable rebuild. -set(slicer_external_disable_update UPDATE_COMMAND "") +set(cmakeversion_external_disable_update UPDATE_COMMAND "") if(CMAKE_VERSION VERSION_LESS 2.8.9) - set(slicer_external_update ${slicer_external_disable_update}) + set(cmakeversion_external_update ${cmakeversion_external_disable_update}) else() - set(slicer_external_update LOG_UPDATE 1) + set(cmakeversion_external_update LOG_UPDATE 1) endif() set(ep_base "${CMAKE_BINARY_DIR}") @@ -90,10 +90,14 @@ endif() #------------------------------------------------------------------------------ # Slicer dependency list #------------------------------------------------------------------------------ +option(USE_SYSTEM_ITK "Build using an externally defined version of ITK" OFF) +option(USE_SYSTEM_SlicerExecutionModel "Build using an externally defined version of SlicerExecutionModel" OFF) +option(USE_SYSTEM_VTK "Build using an externally defined version of VTK" OFF) +option(USE_SYSTEM_DCMTK "Build using an externally defined version of DCMTK" OFF) set(ITK_EXTERNAL_NAME ITKv${ITK_VERSION_MAJOR}) -set(Slicer_DEPENDENCIES cmcurl teem VTK ${ITK_EXTERNAL_NAME} CTK jqPlot LibArchive) +set(Slicer_DEPENDENCIES cmcurl Teem VTK ${ITK_EXTERNAL_NAME} CTK jqPlot LibArchive) if(Slicer_USE_OpenIGTLink) list(APPEND Slicer_DEPENDENCIES OpenIGTLink) @@ -127,7 +131,7 @@ if(Slicer_BUILD_EXTENSIONMANAGER_SUPPORT) list(APPEND Slicer_DEPENDENCIES qMidasAPI) endif() -if(Slicer_BUILD_DICOM_SUPPORT) +if(Slicer_BUILD_DICOM_SUPPORT AND NOT DCMTK_DIR) ## NOTE: if dependancy already added, then don't add it again. list(APPEND Slicer_DEPENDENCIES DCMTK) endif() @@ -167,7 +171,12 @@ if(DEFINED Slicer_ADDITIONAL_DEPENDENCIES) list(APPEND Slicer_DEPENDENCIES ${Slicer_ADDITIONAL_DEPENDENCIES}) endif() -SlicerMacroCheckExternalProjectDependency(Slicer) +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName Slicer) #The find_package known name +set(proj Slicer) #This local name +SlicerMacroCheckExternalProjectDependency(${proj}) #----------------------------------------------------------------------------- # Dump Slicer external project dependencies @@ -364,7 +373,6 @@ endif() #------------------------------------------------------------------------------ # Configure and build Slicer #------------------------------------------------------------------------------ -set(proj Slicer) ExternalProject_Add(${proj} DEPENDS ${Slicer_DEPENDENCIES} diff --git a/SuperBuild/External_BRAINSTools.cmake b/SuperBuild/External_BRAINSTools.cmake index 5e8ae5aa95d170d5052dbaf315d8be1c89219bf5..ca34e80e9f851e906761bc18f51dd3375c2c29aa 100644 --- a/SuperBuild/External_BRAINSTools.cmake +++ b/SuperBuild/External_BRAINSTools.cmake @@ -1,51 +1,99 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName BRAINSTools) #The find_package known name +set(proj BRAINSTools) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED BRAINSTools_SOURCE_DIR AND NOT EXISTS ${BRAINSTools_SOURCE_DIR}) - message(FATAL_ERROR "BRAINSTools_SOURCE_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_SOURCE_DIR AND NOT EXISTS ${${extProjName}_SOURCE_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") endif() # Set dependency list -set(BRAINSTools_DEPENDENCIES ${ITK_EXTERNAL_NAME} SlicerExecutionModel VTK ) +set(${proj}_DEPENDENCIES ${ITK_EXTERNAL_NAME} SlicerExecutionModel VTK ) +if(${PROJECT_NAME}_BUILD_DICOM_SUPPORT) + list(APPEND ${proj}_DEPENDENCIES DCMTK) +endif() # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(BRAINSTools) -set(proj BRAINSTools) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED BRAINSTools_SOURCE_DIR) +if(NOT DEFINED ${extProjName}_SOURCE_DIR) #message(STATUS "${__indent}Adding project ${proj}") -if(${ITK_VERSION_MAJOR} STREQUAL "3") - set(GIT_TAG "fa2159607df370451e7a26d09e4e2a61b6e6c5c8" CACHE STRING "" FORCE) -else() - set(GIT_TAG "796a96d7b0b4c5faf8188919d77ffa863f0af216" CACHE STRING "" FORCE) # 2013-01-07 tag DWIConvert -endif() + + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here if(NOT DEFINED git_protocol) - set(git_protocol "git") + set(git_protocol "git") endif() + set(${proj}_CMAKE_OPTIONS + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY "${git_protocol}://github.com/BRAINSia/BRAINSStandAlone.git") +if(${ITK_VERSION_MAJOR} STREQUAL "3") + set(${proj}_GIT_TAG "fa2159607df370451e7a26d09e4e2a61b6e6c5c8" CACHE STRING "" FORCE) +else() + set(${proj}_GIT_TAG "796a96d7b0b4c5faf8188919d77ffa863f0af216" CACHE STRING "" FORCE) # 2013-01-07 tag DWIConvert +endif() ExternalProject_Add(${proj} - GIT_REPOSITORY "${git_protocol}://github.com/BRAINSia/BRAINSStandAlone.git" - GIT_TAG "${GIT_TAG}" - "${slicer_external_update}" + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} SOURCE_DIR ${proj} BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" CMAKE_GENERATOR ${gen} CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS - ${BRAINSTools_DEPENDENCIES} - ) - set(BRAINSTools_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) else() - # The project is provided using BRAINSTools_DIR, nevertheless since other project may depend on BRAINSTools, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${BRAINSTools_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_BatchMake.cmake b/SuperBuild/External_BatchMake.cmake index 59aa6c1da694904b87b7bf4f9763e281ce8d8e6d..a67bac165840319c0dd364ac51fee25a07be379a 100644 --- a/SuperBuild/External_BatchMake.cmake +++ b/SuperBuild/External_BatchMake.cmake @@ -1,56 +1,104 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName BatchMake) #The find_package known name +set(proj BatchMake) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + # Set dependency list -set(BatchMake_DEPENDENCIES ${ITK_EXTERNAL_NAME}) +set(${proj}_DEPENDENCIES ${ITK_EXTERNAL_NAME}) # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(BatchMake) -set(proj BatchMake) - -# Set CMake OSX variable to pass down the external project -set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) -if(APPLE) - list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS - -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) -endif() +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED git_protocol) - set(git_protocol "git") -endif() +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) + #message(STATUS "${__indent}Adding project ${proj}") + + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here + if(NOT DEFINED git_protocol) + set(git_protocol "git") + endif() -#message(STATUS "${__indent}Adding project ${proj}") -ExternalProject_Add(${proj} - GIT_REPOSITORY "${git_protocol}://batchmake.org/BatchMake.git" - GIT_TAG "1f5bf4f92e8678c34dc6f7558be5e6613804d988" - "${slicer_external_update}" - SOURCE_DIR BatchMake - BINARY_DIR BatchMake-build - CMAKE_GENERATOR ${gen} - CMAKE_ARGS - -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} - -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} - -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} - -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} - ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DBUILD_TESTING:BOOL=OFF - -DBUILD_SHARED_LIBS:BOOL=ON - -DUSE_FLTK:BOOL=OFF - -DDASHBOARD_SUPPORT:BOOL=OFF - -DGRID_SUPPORT:BOOL=ON - -DUSE_SPLASHSCREEN:BOOL=OFF - -DITK_DIR:PATH=${ITK_DIR} - INSTALL_COMMAND "" - DEPENDS - ${BatchMake_DEPENDENCIES} + set(${proj}_CMAKE_OPTIONS + -DBUILD_TESTING:BOOL=OFF + -DBUILD_SHARED_LIBS:BOOL=ON + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DUSE_FLTK:BOOL=OFF + -DDASHBOARD_SUPPORT:BOOL=OFF + -DGRID_SUPPORT:BOOL=ON + -DUSE_SPLASHSCREEN:BOOL=OFF + -DITK_DIR:PATH=${ITK_DIR} ) + ### --- End Project specific additions + set(${proj}_REPOSITORY "${git_protocol}://batchmake.org/BatchMake.git") + set(${proj}_GIT_TAG "1f5bf4f92e8678c34dc6f7558be5e6613804d988") + ExternalProject_Add(${proj} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} + BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" + CMAKE_GENERATOR ${gen} + CMAKE_ARGS + -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} + ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + ${${proj}_CMAKE_OPTIONS} + INSTALL_COMMAND "" + DEPENDS + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}-build) +else() + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") +endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) -set(BatchMake_DIR ${CMAKE_BINARY_DIR}/BatchMake-build) +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_CTK.cmake b/SuperBuild/External_CTK.cmake index 825354f752a9ed88bec115eeab31037edd32e74c..248cafebd214e60645870a0c66bb2c6f4087b1a6 100644 --- a/SuperBuild/External_CTK.cmake +++ b/SuperBuild/External_CTK.cmake @@ -1,30 +1,48 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName CTK) #The find_package known name +set(proj CTK) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED CTK_DIR AND NOT EXISTS ${CTK_DIR}) - message(FATAL_ERROR "CTK_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") endif() # Set dependency list -set(CTK_DEPENDENCIES VTK ${ITK_EXTERNAL_NAME}) -if(Slicer_USE_PYTHONQT) - list(APPEND CTK_DEPENDENCIES python) +set(${proj}_DEPENDENCIES VTK ${ITK_EXTERNAL_NAME}) +if(${PROJECT_NAME}_USE_PYTHONQT) + list(APPEND ${proj}_DEPENDENCIES python) endif() -if(Slicer_BUILD_DICOM_SUPPORT) - list(APPEND CTK_DEPENDENCIES DCMTK) +if(${PROJECT_NAME}_BUILD_DICOM_SUPPORT) + list(APPEND ${proj}_DEPENDENCIES DCMTK) endif() # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(CTK) -set(proj CTK) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED CTK_DIR) +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) #message(STATUS "${__indent}Adding project ${proj}") # Set CMake OSX variable to pass down the external project @@ -36,55 +54,44 @@ if(NOT DEFINED CTK_DIR) -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) endif() + ### --- Project specific additions here set(optional_ep_args) - if(Slicer_USE_PYTHONQT) + if(${PROJECT_NAME}_USE_PYTHONQT) list(APPEND optional_ep_args -DPYTHON_LIBRARY:FILEPATH=${slicer_PYTHON_LIBRARY} -DPYTHON_INCLUDE_DIR:PATH=${slicer_PYTHON_INCLUDE} -DPYTHON_EXECUTABLE:FILEPATH=${slicer_PYTHON_EXECUTABLE} - -DCTK_LIB_Scripting/Python/Core:BOOL=${Slicer_USE_PYTHONQT} - -DCTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK:BOOL=${Slicer_USE_PYTHONQT} - -DCTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTCORE:BOOL=${Slicer_USE_PYTHONQT} - -DCTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTGUI:BOOL=${Slicer_USE_PYTHONQT} - -DCTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTUITOOLS:BOOL=${Slicer_USE_PYTHONQT} - -DCTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTNETWORK:BOOL=${Slicer_USE_PYTHONQT} - -DCTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTWEBKIT:BOOL=${Slicer_USE_PYTHONQT} - -DCTK_LIB_Scripting/Python/Widgets:BOOL=${Slicer_USE_PYTHONQT} - -DCTK_ENABLE_Python_Wrapping:BOOL=${Slicer_USE_PYTHONQT} + -DCTK_LIB_Scripting/Python/Core:BOOL=${${PROJECT_NAME}_USE_PYTHONQT} + -DCTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK:BOOL=${${PROJECT_NAME}_USE_PYTHONQT} + -DCTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTCORE:BOOL=${${PROJECT_NAME}_USE_PYTHONQT} + -DCTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTGUI:BOOL=${${PROJECT_NAME}_USE_PYTHONQT} + -DCTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTUITOOLS:BOOL=${${PROJECT_NAME}_USE_PYTHONQT} + -DCTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTNETWORK:BOOL=${${PROJECT_NAME}_USE_PYTHONQT} + -DCTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTWEBKIT:BOOL=${${PROJECT_NAME}_USE_PYTHONQT} + -DCTK_LIB_Scripting/Python/Widgets:BOOL=${${PROJECT_NAME}_USE_PYTHONQT} + -DCTK_ENABLE_Python_Wrapping:BOOL=${${PROJECT_NAME}_USE_PYTHONQT} ) endif() - if(Slicer_BUILD_DICOM_SUPPORT) + if(${PROJECT_NAME}_BUILD_DICOM_SUPPORT) list(APPEND optional_ep_args -DDCMTK_DIR:PATH=${DCMTK_DIR} ) endif() if(NOT DEFINED git_protocol) - set(git_protocol "git") + set(git_protocol "git") endif() - ExternalProject_Add(${proj} - GIT_REPOSITORY "${git_protocol}://github.com/commontk/CTK.git" - GIT_TAG "b183487871c43408890b2785e58643ba8d6b1b13" - "${slicer_external_update}" - SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} - BINARY_DIR ${proj}-build - CMAKE_GENERATOR ${gen} - CMAKE_ARGS - -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} - -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} - -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} - -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} - ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + set(${proj}_CMAKE_OPTIONS + -DBUILD_TESTING:BOOL=OFF -DADDITIONAL_C_FLAGS:STRING=${ADDITIONAL_C_FLAGS} -DADDITIONAL_CXX_FLAGS:STRING=${ADDITIONAL_CXX_FLAGS} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DBUILD_TESTING:BOOL=OFF - -DCTK_INSTALL_BIN_DIR:STRING=${Slicer_INSTALL_BIN_DIR} - -DCTK_INSTALL_LIB_DIR:STRING=${Slicer_INSTALL_LIB_DIR} - -DCTK_INSTALL_QTPLUGIN_DIR:STRING=${Slicer_INSTALL_QtPlugins_DIR} - -DCTK_USE_GIT_PROTOCOL:BOOL=${Slicer_USE_GIT_PROTOCOL} + -DCTK_INSTALL_BIN_DIR:STRING=${${PROJECT_NAME}_INSTALL_BIN_DIR} + -DCTK_INSTALL_LIB_DIR:STRING=${${PROJECT_NAME}_INSTALL_LIB_DIR} + -DCTK_INSTALL_QTPLUGIN_DIR:STRING=${${PROJECT_NAME}_INSTALL_QtPlugins_DIR} + -DCTK_USE_GIT_PROTOCOL:BOOL=${${PROJECT_NAME}_USE_GIT_PROTOCOL} -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DVTK_DIR:PATH=${VTK_DIR} -DITK_DIR:PATH=${ITK_DIR} @@ -94,20 +101,49 @@ if(NOT DEFINED CTK_DIR) -DCTK_LIB_ImageProcessing/ITK/Core:BOOL=ON -DCTK_LIB_PluginFramework:BOOL=OFF -DCTK_PLUGIN_org.commontk.eventbus:BOOL=OFF - -DCTK_APP_ctkDICOM:BOOL=${Slicer_BUILD_DICOM_SUPPORT} - -DCTK_LIB_DICOM/Core:BOOL=${Slicer_BUILD_DICOM_SUPPORT} - -DCTK_LIB_DICOM/Widgets:BOOL=${Slicer_BUILD_DICOM_SUPPORT} - -DCTK_USE_QTTESTING:BOOL=${Slicer_USE_QtTesting} + -DCTK_APP_ctkDICOM:BOOL=${${PROJECT_NAME}_BUILD_DICOM_SUPPORT} + -DCTK_LIB_DICOM/Core:BOOL=${${PROJECT_NAME}_BUILD_DICOM_SUPPORT} + -DCTK_LIB_DICOM/Widgets:BOOL=${${PROJECT_NAME}_BUILD_DICOM_SUPPORT} + -DCTK_USE_QTTESTING:BOOL=${${PROJECT_NAME}_USE_QtTesting} -DGIT_EXECUTABLE:FILEPATH=${GIT_EXECUTABLE} ${optional_ep_args} + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY "${git_protocol}://github.com/commontk/CTK.git") + set(${proj}_GIT_TAG "b183487871c43408890b2785e58643ba8d6b1b13") + ExternalProject_Add(${proj} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} + BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" + CMAKE_GENERATOR ${gen} + CMAKE_ARGS + -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} + ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + ${${proj}_CMAKE_OPTIONS} INSTALL_COMMAND "" DEPENDS - ${CTK_DEPENDENCIES} - ) - set(CTK_DIR ${CMAKE_BINARY_DIR}/${proj}-build) - + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}-build) else() - # The project is provided using CTK_DIR, nevertheless since other project may depend on CTK, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${CTK_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_CTKAPPLAUNCHER.cmake b/SuperBuild/External_CTKAPPLAUNCHER.cmake index ee90d73fc5e8bcb4c6ec466e8a9f700942c73be3..2b0f4a20d32b0dff01cee7579988a24a2c405516 100644 --- a/SuperBuild/External_CTKAPPLAUNCHER.cmake +++ b/SuperBuild/External_CTKAPPLAUNCHER.cmake @@ -1,57 +1,98 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) -if(Slicer_USE_CTKAPPLAUNCHER) - # Sanity checks - if(DEFINED CTKAPPLAUNCHER_DIR AND NOT EXISTS ${CTKAPPLAUNCHER_DIR}) - message(FATAL_ERROR "CTKAPPLAUNCHER_DIR variable is defined but corresponds to non-existing directory") +if(${PROJECT_NAME}_USE_CTKAPPLAUNCHER) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName CTKAPPLAUNCHER) #The find_package known name +set(proj CTKAPPLAUNCHER) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + +# Set dependency list +set(${proj}_DEPENDENCIES "") + +# Include dependent projects if any +SlicerMacroCheckExternalProjectDependency(${proj}) + +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) + #message(STATUS "${__indent}Adding project ${proj}") + + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) endif() - # Set dependency list - set(CTKAPPLAUNCHER_DEPENDENCIES "") - - # Include dependent projects if any - SlicerMacroCheckExternalProjectDependency(CTKAPPLAUNCHER) - set(proj CTKAPPLAUNCHER) - - if(NOT DEFINED CTKAPPLAUNCHER_DIR) - SlicerMacroGetOperatingSystemArchitectureBitness(VAR_PREFIX CTKAPPLAUNCHER) - set(launcher_version "0.1.10") - set(item_id "") - # On windows, use i386 launcher unconditionally - if("${CTKAPPLAUNCHER_OS}" STREQUAL "win") - set(CTKAPPLAUNCHER_ARCHITECTURE "i386") - set(md5 "fee82ee869cfedb54f48c58d0bad3710") - set(item_id "53") - elseif("${CTKAPPLAUNCHER_OS}" STREQUAL "linux") - set(md5 "7da4bcc68ab09833aebc156a7d0a5f06") - set(item_id "65") - elseif("${CTKAPPLAUNCHER_OS}" STREQUAL "macosx") - set(md5 "de87ffad9d5909c7525c61dac50b0c9e") - set(item_id "63") + ### --- Project specific additions here + SlicerMacroGetOperatingSystemArchitectureBitness(VAR_PREFIX CTKAPPLAUNCHER) + set(launcher_version "0.1.10") + set(item_id "") + # On windows, use i386 launcher unconditionally + if("${CTKAPPLAUNCHER_OS}" STREQUAL "win") + set(CTKAPPLAUNCHER_ARCHITECTURE "i386") + set(md5 "fee82ee869cfedb54f48c58d0bad3710") + set(item_id "53") + elseif("${CTKAPPLAUNCHER_OS}" STREQUAL "linux") + set(md5 "7da4bcc68ab09833aebc156a7d0a5f06") + set(item_id "65") + elseif("${CTKAPPLAUNCHER_OS}" STREQUAL "macosx") + set(md5 "de87ffad9d5909c7525c61dac50b0c9e") + set(item_id "63") + endif() + ### --- End Project specific additions + ExternalProject_Add(${proj} + URL http://packages.kitware.com/api/rest?method=midas.item.download&id=${item_id}&dummy=CTKAppLauncher-${launcher_version}-${CTKAPPLAUNCHER_OS}-${CTKAPPLAUNCHER_ARCHITECTURE}.tar.gz + URL_MD5 ${md5} + SOURCE_DIR ${proj} + "${cmakeversion_external_update}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + DEPENDS + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}) +else() + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") endif() - #message(STATUS "${__indent}Adding project ${proj}") - ExternalProject_Add(${proj} - URL http://packages.kitware.com/api/rest?method=midas.item.download&id=${item_id}&dummy=CTKAppLauncher-${launcher_version}-${CTKAPPLAUNCHER_OS}-${CTKAPPLAUNCHER_ARCHITECTURE}.tar.gz - URL_MD5 ${md5} - SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} - "${slicer_external_update}" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - DEPENDS - ${CTKAPPLAUNCHER_DEPENDENCIES} - ) - set(CTKAPPLAUNCHER_DIR ${CMAKE_BINARY_DIR}/${proj}) - else() - # The project is provided using CTKAPPLAUNCHER_DIR, nevertheless since other - # project may depend on CTKAPPLAUNCHER, let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${CTKAPPLAUNCHER_DEPENDENCIES}") + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") +endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) endif() diff --git a/SuperBuild/External_ChangeTrackerPy.cmake b/SuperBuild/External_ChangeTrackerPy.cmake index e1b4358a67a35f9733896bce6465dc8d7eb9382b..c553b173ed40add89e400958a1c90113893917cb 100644 --- a/SuperBuild/External_ChangeTrackerPy.cmake +++ b/SuperBuild/External_ChangeTrackerPy.cmake @@ -1,46 +1,91 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName ChangeTrackerPy) #The find_package known name +set(proj ChangeTrackerPy) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED ChangeTrackerPy_SOURCE_DIR AND NOT EXISTS ${ChangeTrackerPy_SOURCE_DIR}) - message(FATAL_ERROR "ChangeTrackerPy_SOURCE_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_SOURCE_DIR AND NOT EXISTS ${${extProjName}_SOURCE_DIR}) + message(FATAL_ERROR "${extProjName}_SOURCE_DIR variable is defined but corresponds to non-existing directory") endif() # Set dependency list -set(ChangeTrackerPy_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(ChangeTrackerPy) -set(proj ChangeTrackerPy) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED ChangeTrackerPy_SOURCE_DIR) +if(NOT DEFINED ${extProjName}_SOURCE_DIR) #message(STATUS "${__indent}Adding project ${proj}") + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here if(NOT DEFINED git_protocol) - set(git_protocol "git") + set(git_protocol "git") endif() + set(${proj}_CMAKE_OPTIONS + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY "${git_protocol}://github.com/fedorov/ChangeTrackerPy.git") + set(${proj}_GIT_TAG "6459708494ebdf7ae8c25cf771397a40ba63c248") ExternalProject_Add(${proj} - GIT_REPOSITORY "${git_protocol}://github.com/fedorov/ChangeTrackerPy.git" - GIT_TAG "6459708494ebdf7ae8c25cf771397a40ba63c248" - "${slicer_external_update}" - SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" CMAKE_GENERATOR ${gen} CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS - ${ChangeTrackerPy_DEPENDENCIES} + ${${proj}_DEPENDENCIES} ) - set(ChangeTrackerPy_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) + set(${extProjName}_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) else() - # The project is provided using ChangeTrackerPy_DIR, nevertheless since other project may depend on EMSegment, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${ChangeTrackerPy_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_DCMTK.cmake b/SuperBuild/External_DCMTK.cmake index cdf0717289784110e9b8a5297a15e55eeae15874..065570c984e22baf931c7d03aa8ee473c57fd477 100644 --- a/SuperBuild/External_DCMTK.cmake +++ b/SuperBuild/External_DCMTK.cmake @@ -1,19 +1,44 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName DCMTK) #The find_package known name +set(proj DCMTK) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + # Set dependency list -set(DCMTK_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(DCMTK) -set(proj DCMTK) +SlicerMacroCheckExternalProjectDependency(${proj}) + +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) + #message(STATUS "${__indent}Adding project ${proj}") -if(NOT DEFINED DCMTK_DIR) # Set CMake OSX variable to pass down the external project set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) if(APPLE) @@ -26,47 +51,62 @@ if(NOT DEFINED DCMTK_DIR) set(CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG) if(CTEST_USE_LAUNCHERS) set(CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG - "-DCMAKE_PROJECT_DCMTK_INCLUDE:FILEPATH=${CMAKE_ROOT}/Modules/CTestUseLaunchers.cmake") + "-DCMAKE_PROJECT_${proj}_INCLUDE:FILEPATH=${CMAKE_ROOT}/Modules/CTestUseLaunchers.cmake") endif() - set(DCMTK_REPOSITORY ${git_protocol}://github.com/commontk/DCMTK.git) - set(DCMTK_GIT_TAG "d06e2b7d9bafb23df4e969482a68b50fc75aaaa9") - + ### --- Project specific additions here + set(${proj}_CMAKE_OPTIONS + -DDCMTK_WITH_DOXYGEN:BOOL=OFF + -DDCMTK_WITH_ZLIB:BOOL=OFF # see CTK github issue #25 + -DDCMTK_WITH_OPENSSL:BOOL=OFF # see CTK github issue #25 + -DDCMTK_WITH_PNG:BOOL=OFF # see CTK github issue #25 + -DDCMTK_WITH_TIFF:BOOL=OFF # see CTK github issue #25 + -DDCMTK_WITH_XML:BOOL=OFF # see CTK github issue #25 + -DDCMTK_WITH_ICONV:BOOL=OFF # see CTK github issue #178 + -DDCMTK_FORCE_FPIC_ON_UNIX:BOOL=ON + -DDCMTK_OVERWRITE_WIN32_COMPILER_FLAGS:BOOL=OFF + -DDCMTK_WITH_WRAP:BOOL=OFF # CTK does not build on Mac with this option turned ON due to library dependencies missing + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY ${git_protocol}://github.com/commontk/DCMTK.git) + set(${proj}_GIT_TAG "d06e2b7d9bafb23df4e969482a68b50fc75aaaa9") ExternalProject_Add(${proj} - GIT_REPOSITORY ${DCMTK_REPOSITORY} - GIT_TAG ${DCMTK_GIT_TAG} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} SOURCE_DIR ${proj} BINARY_DIR ${proj}-build INSTALL_DIR ${proj}-install - "${slicer_external_update}" + "${cmakeversion_external_update}" CMAKE_GENERATOR ${gen} CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} + -DCMAKE_INSTALL_PREFIX:PATH= ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} ${CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS:BOOL=OFF - -DDCMTK_WITH_DOXYGEN:BOOL=OFF - -DDCMTK_WITH_ZLIB:BOOL=OFF # see CTK github issue #25 - -DDCMTK_WITH_OPENSSL:BOOL=OFF # see CTK github issue #25 - -DDCMTK_WITH_PNG:BOOL=OFF # see CTK github issue #25 - -DDCMTK_WITH_TIFF:BOOL=OFF # see CTK github issue #25 - -DDCMTK_WITH_XML:BOOL=OFF # see CTK github issue #25 - -DDCMTK_WITH_ICONV:BOOL=OFF # see CTK github issue #178 - -DDCMTK_FORCE_FPIC_ON_UNIX:BOOL=ON - -DDCMTK_OVERWRITE_WIN32_COMPILER_FLAGS:BOOL=OFF - -DDCMTK_WITH_WRAP:BOOL=OFF # CTK does not build on Mac with this option turned ON due to library dependencies missing + ${${proj}_CMAKE_OPTIONS} DEPENDS - ${DCMTK_DEPENDENCIES} + ${${proj}_DEPENDENCIES} ) - - set(DCMTK_DIR ${CMAKE_BINARY_DIR}/${proj}-install) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}-install) else() - # The project is provided with DCMTK_DIR, nevertheless since other project may depend on DCMTK_DIR, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${DCMTK_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_EMSegment.cmake b/SuperBuild/External_EMSegment.cmake index 2c01df78c91255c6ae7fdc6e969b19fcf0898e13..09409e2680da71a23d97174f797cfba03fb38c3e 100644 --- a/SuperBuild/External_EMSegment.cmake +++ b/SuperBuild/External_EMSegment.cmake @@ -1,41 +1,85 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName EMSegment) #The find_package known name +set(proj EMSegment) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED EMSegment_SOURCE_DIR AND NOT EXISTS ${EMSegment_SOURCE_DIR}) - message(FATAL_ERROR "EMSegment_SOURCE_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_SOURCE_DIR AND NOT EXISTS ${${extProjName}_SOURCE_DIR}) + message(FATAL_ERROR "${extProjName}_SOURCE_DIR variable is defined but corresponds to non-existing directory") endif() # Set dependency list -set(EMSegment_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(EMSegment) -set(proj EMSegment) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED EMSegment_SOURCE_DIR) +if(NOT DEFINED ${extProjName}_SOURCE_DIR) #message(STATUS "${__indent}Adding project ${proj}") + + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here + set(${proj}_CMAKE_OPTIONS + ) + ### --- End Project specific additions ExternalProject_Add(${proj} SVN_REPOSITORY "http://svn.slicer.org/Slicer3/trunk/Modules/EMSegment" SVN_REVISION -r "17018" - "${slicer_external_update}" SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" CMAKE_GENERATOR ${gen} CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS - ${EMSegment_DEPENDENCIES} - ) - set(EMSegment_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) else() - # The project is provided using EMSegment_DIR, nevertheless since other project may depend on EMSegment, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${EMSegment_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_ITKv3.cmake b/SuperBuild/External_ITKv3.cmake index c5dabd92d4d8bb02aa61dcc38e339f7ddad8abbf..06a0a71abc5eda288681be2e87efbd46fc63f95e 100644 --- a/SuperBuild/External_ITKv3.cmake +++ b/SuperBuild/External_ITKv3.cmake @@ -1,24 +1,42 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName ITK) #The find_package known name +set(proj ITKv3) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED ITK_DIR AND NOT EXISTS ${ITK_DIR}) - message(FATAL_ERROR "ITK_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") endif() # Set dependency list -set(ITKv3_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(ITKv3) -set(proj ITKv3) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED ITK_DIR) +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) #message(STATUS "${__indent}Adding project ${proj}") # Set CMake OSX variable to pass down the external project @@ -30,57 +48,70 @@ if(NOT DEFINED ITK_DIR) -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) endif() + ### --- Project specific additions here set(CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG) if(CTEST_USE_LAUNCHERS) set(CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG "-DCMAKE_PROJECT_ITK_INCLUDE:FILEPATH=${CMAKE_ROOT}/Modules/CTestUseLaunchers.cmake") endif() - set(${CMAKE_PROJECT_NAME}_${proj}_GIT_REPOSITORY "github.com/Kitware/ITK.git" CACHE STRING "Repository from which to get ITK" FORCE) - # release-3.20 branch on 2012-11-27. - set(${CMAKE_PROJECT_NAME}_${proj}_GIT_TAG "787200e5250da02069964063548a39d5e46662e2" CACHE STRING "ITK git tag to use" FORCE) - - mark_as_advanced(${CMAKE_PROJECT_NAME}_${proj}_GIT_REPOSITORY ${CMAKE_PROJECT_NAME}_${proj}_GIT_TAG) if(NOT DEFINED git_protocol) - set(git_protocol "git") + set(git_protocol "git") endif() - ExternalProject_Add(${proj} - GIT_REPOSITORY "${git_protocol}://${${CMAKE_PROJECT_NAME}_${proj}_GIT_REPOSITORY}" - GIT_TAG ${${CMAKE_PROJECT_NAME}_${proj}_GIT_TAG} - "${slicer_external_update}" - SOURCE_DIR ${proj} - BINARY_DIR ${proj}-build - CMAKE_GENERATOR ${gen} - CMAKE_ARGS - -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} - -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} - -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} - -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} - ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + set(${proj}_CMAKE_OPTIONS ${CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DBUILD_TESTING:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS:BOOL=ON - -DBUILD_TESTING:BOOL=OFF - -DITK_INSTALL_LIB_DIR:PATH=${Slicer_INSTALL_LIB_DIR} + -DITK_INSTALL_LIB_DIR:PATH=${${PROJECT_NAME}_INSTALL_LIB_DIR} + -DITK_LEGACY_REMOVE:BOOL=ON -DITK_USE_REVIEW:BOOL=ON -DITK_USE_REVIEW_STATISTICS:BOOL=ON -DITK_USE_OPTIMIZED_REGISTRATION_METHODS:BOOL=ON #-DITK_USE_PORTABLE_ROUND:BOOL=ON # Unused -DITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY:BOOL=ON -DITK_USE_TRANSFORM_IO_FACTORIES:BOOL=ON - -DITK_LEGACY_REMOVE:BOOL=ON -DKWSYS_USE_MD5:BOOL=ON # Required by SlicerExecutionModel + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY ${git_protocol}://itk.org/ITK.git) + set(${proj}_GIT_TAG 787200e5250da02069964063548a39d5e46662e2) + ExternalProject_Add(${proj} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} + BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" + CMAKE_GENERATOR ${gen} + CMAKE_ARGS + -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} + ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + ${${proj}_CMAKE_OPTIONS} INSTALL_COMMAND "" DEPENDS - ${ITKv3_DEPENDENCIES} - ) - set(ITK_DIR ${CMAKE_BINARY_DIR}/${proj}-build) - + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}-build) else() - # The project is provided using ITK_DIR, nevertheless since other project may depend on ITK, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${ITKv3_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_ITKv4.cmake b/SuperBuild/External_ITKv4.cmake index efa09aa88aa0325d017e978894bb924a4d1ffd82..fec21d7a73ce9d810a1a04cfdcd9567fb289b2ca 100644 --- a/SuperBuild/External_ITKv4.cmake +++ b/SuperBuild/External_ITKv4.cmake @@ -1,27 +1,45 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName ITK) #The find_package known name +set(proj ITKv4) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED ITK_DIR AND NOT EXISTS ${ITK_DIR}) - message(FATAL_ERROR "ITK_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") endif() # Set dependency list -set(ITKv4_DEPENDENCIES "") -if(Slicer_BUILD_DICOM_SUPPORT) - list(APPEND ITKv4_DEPENDENCIES DCMTK) +set(${proj}_DEPENDENCIES "") +if(${PROJECT_NAME}_BUILD_DICOM_SUPPORT) + list(APPEND ${proj}_DEPENDENCIES DCMTK) endif() # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(ITKv4) -set(proj ITKv4) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED ITK_DIR) +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) #message(STATUS "${__indent}Adding project ${proj}") # Set CMake OSX variable to pass down the external project @@ -33,18 +51,30 @@ if(NOT DEFINED ITK_DIR) -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) endif() - set(ITKv4_DCMTK_ARGS) - if(Slicer_BUILD_DICOM_SUPPORT) - set(ITKv4_DCMTK_ARGS + ### --- Project specific additions here + set(${proj}_DCMTK_ARGS) + if(${PROJECT_NAME}_BUILD_DICOM_SUPPORT) + set(${proj}_DCMTK_ARGS -DITK_USE_SYSTEM_DCMTK:BOOL=ON -DDCMTK_DIR:PATH=${DCMTK_DIR} -DModule_ITKIODCMTK:BOOL=ON ) endif() - set(ITKv4_WRAP_ARGS) + if(${PROJECT_NAME}_BUILD_FFTWF_SUPPORT) + set(${proj}_FFTWF_ARGS + -DITK_USE_FFTWF:BOOL=ON + ) + endif() + if(${PROJECT_NAME}_BUILD_FFTWD_SUPPORT) + set(${proj}_FFTWD_ARGS + -DITK_USE_FFTWD:BOOL=ON + ) + endif() + + set(${proj}_WRAP_ARGS) #if(foo) - #set(ITKv4_WRAP_ARGS + #set(${proj}_WRAP_ARGS # -DINSTALL_WRAP_ITK_COMPATIBILITY:BOOL=OFF # -DWRAP_float:BOOL=ON # -DWRAP_unsigned_char:BOOL=ON @@ -74,47 +104,63 @@ if(NOT DEFINED ITK_DIR) set(git_protocol "git") endif() - set(ITKv4_REPOSITORY ${git_protocol}://itk.org/ITK.git) - set(ITKv4_GIT_TAG c313377e1b54c82f4e5f4941edb55f8e5a3af733) # 2013-01-06 - - ExternalProject_Add(${proj} - GIT_REPOSITORY ${ITKv4_REPOSITORY} - GIT_TAG ${ITKv4_GIT_TAG} - "${slicer_external_update}" - SOURCE_DIR ${proj} - BINARY_DIR ${proj}-build - CMAKE_GENERATOR ${gen} - CMAKE_ARGS - -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} - -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} - -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} - -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} - ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} - -DITK_INSTALL_ARCHIVE_DIR:PATH=${Slicer_INSTALL_LIB_DIR} - -DITK_INSTALL_LIBRARY_DIR:PATH=${Slicer_INSTALL_LIB_DIR} + set(${proj}_CMAKE_OPTIONS -DBUILD_TESTING:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DBUILD_SHARED_LIBS:BOOL=ON + -DITK_INSTALL_ARCHIVE_DIR:PATH=${${PROJECT_NAME}_INSTALL_LIB_DIR} + -DITK_INSTALL_LIBRARY_DIR:PATH=${${PROJECT_NAME}_INSTALL_LIB_DIR} -DITK_LEGACY_REMOVE:BOOL=OFF -DITKV3_COMPATIBILITY:BOOL=ON -DITK_BUILD_ALL_MODULES:BOOL=ON -DITK_USE_REVIEW:BOOL=ON - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DBUILD_SHARED_LIBS:BOOL=ON -DITK_INSTALL_NO_DEVELOPMENT:BOOL=ON -DITK_BUILD_ALL_MODULES:BOOL=ON -DKWSYS_USE_MD5:BOOL=ON # Required by SlicerExecutionModel -DITK_WRAPPING:BOOL=OFF #${BUILD_SHARED_LIBS} ## HACK: QUICK CHANGE - -DITK_USE_SYSTEM_DCMTK:BOOL=${Slicer_BUILD_DICOM_SUPPORT} - ${ITKv4_DCMTK_ARGS} - ${ITKv4_WRAP_ARGS} + -DITK_USE_SYSTEM_DCMTK:BOOL=${${PROJECT_NAME}_BUILD_DICOM_SUPPORT} + ${${proj}_DCMTK_ARGS} + ${${proj}_WRAP_ARGS} + ${${proj}_FFTWF_ARGS} + ${${proj}_FFTWD_ARGS} + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY ${git_protocol}://itk.org/ITK.git) + set(${proj}_GIT_TAG c313377e1b54c82f4e5f4941edb55f8e5a3af733) # 2013-01-06 + ExternalProject_Add(${proj} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} + BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" + CMAKE_GENERATOR ${gen} + CMAKE_ARGS + -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} + ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + ${${proj}_CMAKE_OPTIONS} INSTALL_COMMAND "" DEPENDS - ${ITKv4_DEPENDENCIES} - ) - set(ITK_DIR ${CMAKE_BINARY_DIR}/${proj}-build) - + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}-build) else() - # The project is provided using ITK_DIR, nevertheless since other project may depend on ITK, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${ITKv4_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_LibArchive.cmake b/SuperBuild/External_LibArchive.cmake index 982e4b663bd10a3f6e6db1afb87cc405b4c51d0c..31bb44dc9ce0070ea6f0d07cbd928fc7a13f1ea8 100644 --- a/SuperBuild/External_LibArchive.cmake +++ b/SuperBuild/External_LibArchive.cmake @@ -1,28 +1,57 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName LibArchive) #The find_package known name +set(proj LibArchive) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED LibArchive_DIR AND NOT EXISTS ${LibArchive_DIR}) - message(FATAL_ERROR "LibArchive_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") endif() # Set dependency list -set(LibArchive_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") if(WIN32) - list(APPEND LibArchive_DEPENDENCIES zlib) + list(APPEND ${proj}_DEPENDENCIES zlib) endif() # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(LibArchive) -set(proj LibArchive) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED LibArchive_DIR) +if(NOT DEFINED ${extProjName}_DIR) #message(STATUS "${__indent}Adding project ${proj}") + + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here # # NOTE: - a stable, recent release (3.0.4) of LibArchive is now checked out from git # for all platforms. For notes on cross-platform issues with earlier versions @@ -42,27 +71,31 @@ if(NOT DEFINED LibArchive_DIR) -DBUILD_TESTING:BOOL=OFF -DENABLE_OPENSSL:BOOL=OFF ) - - # Set CMake OSX variable to pass down the external project - set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) - if(APPLE) - list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS - -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) - endif() - if(NOT DEFINED git_protocol) - set(git_protocol "git") + set(git_protocol "git") endif() + set(${proj}_CMAKE_OPTIONS + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DBUILD_SHARED_LIBS:BOOL=ON + -DENABLE_ACL:BOOL=OFF + -DENABLE_CPIO:BOOL=OFF + -DENABLE_TAR:BOOL=OFF + -DENABLE_TEST:BOOL=OFF + -DENABLE_XATTR:BOOL=OFF + ${ADDITIONAL_CMAKE_ARGS} + -DCMAKE_INSTALL_PREFIX:PATH= + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY "${git_protocol}://github.com/libarchive/libarchive.git") + set(${proj}_GIT_TAG "v3.0.4") ExternalProject_Add(${proj} - GIT_REPOSITORY "${git_protocol}://github.com/libarchive/libarchive.git" - GIT_TAG "v3.0.4" - SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} BINARY_DIR ${proj}-build INSTALL_DIR LibArchive-install - "${slicer_external_update}" + "${cmakeversion_external_update}" CMAKE_GENERATOR ${gen} CMAKE_ARGS # Not used -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} @@ -70,21 +103,25 @@ if(NOT DEFINED LibArchive_DIR) -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DBUILD_SHARED_LIBS:BOOL=ON - -DENABLE_ACL:BOOL=OFF - -DENABLE_CPIO:BOOL=OFF - -DENABLE_TAR:BOOL=OFF - -DENABLE_TEST:BOOL=OFF - -DENABLE_XATTR:BOOL=OFF - ${ADDITIONAL_CMAKE_ARGS} - -DCMAKE_INSTALL_PREFIX:PATH= + ${${proj}_CMAKE_OPTIONS} DEPENDS - ${LibArchive_DEPENDENCIES} - ) - set(LibArchive_DIR ${CMAKE_BINARY_DIR}/LibArchive-install) + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}-install) else() - # The project is provided using LibArchive_DIR, nevertheless since other project may depend on LibArchive, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${LibArchive_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_MultiVolumeExplorer.cmake b/SuperBuild/External_MultiVolumeExplorer.cmake index 808a48fcc7a99c0c913cb22f4d8a1b161d51ca26..86c2dbc1f16508c6a0266dcc1465ba4115fe8a08 100644 --- a/SuperBuild/External_MultiVolumeExplorer.cmake +++ b/SuperBuild/External_MultiVolumeExplorer.cmake @@ -1,46 +1,91 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName MultiVolumeExplorer) #The find_package known name +set(proj MultiVolumeExplorer) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED MultiVolumeExplorer_SOURCE_DIR AND NOT EXISTS ${MultiVolumeExplorer_SOURCE_DIR}) - message(FATAL_ERROR "MultiVolumeExplorer_SOURCE_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_SOURCE_DIR AND NOT EXISTS ${${extProjName}_SOURCE_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") endif() # Set dependency list -set(MultiVolumeExplorer_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(MultiVolumeExplorer) -set(proj MultiVolumeExplorer) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED MultiVolumeExplorer_SOURCE_DIR) +if(NOT DEFINED ${extProjName}_SOURCE_DIR) #message(STATUS "${__indent}Adding project ${proj}") + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here if(NOT DEFINED git_protocol) - set(git_protocol "git") + set(git_protocol "git") endif() + set(${proj}_CMAKE_OPTIONS + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY "${git_protocol}://github.com/fedorov/MultiVolumeExplorer.git") + set(${proj}_GIT_TAG "72d55d2ab12e7301ca8ced49ad05ce28346e625d") ExternalProject_Add(${proj} - GIT_REPOSITORY "${git_protocol}://github.com/fedorov/MultiVolumeExplorer.git" - GIT_TAG "72d55d2ab12e7301ca8ced49ad05ce28346e625d" - "${slicer_external_update}" - SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" CMAKE_GENERATOR ${gen} CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS - ${MultiVolumeExplorer_DEPENDENCIES} - ) - set(MultiVolumeExplorer_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) else() - # The project is provided using MultiVolumeExplorer_DIR, nevertheless since other project may depend on EMSegment, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${MultiVolumeExplorer_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_MultiVolumeImporter.cmake b/SuperBuild/External_MultiVolumeImporter.cmake index d9bd6415480ead38e7bc2cd65e862fc53c05a82e..1ac681e5f84ec5310603cde1174aae6a372a3471 100644 --- a/SuperBuild/External_MultiVolumeImporter.cmake +++ b/SuperBuild/External_MultiVolumeImporter.cmake @@ -1,46 +1,91 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName MultiVolumeImporter) #The find_package known name +set(proj MultiVolumeImporter) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED MultiVolumeImporter_SOURCE_DIR AND NOT EXISTS ${MultiVolumeImporter_SOURCE_DIR}) - message(FATAL_ERROR "MultiVolumeImporter_SOURCE_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_SOURCE_DIR AND NOT EXISTS ${${extProjName}_SOURCE_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") endif() # Set dependency list -set(MultiVolumeImporter_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(MultiVolumeImporter) -set(proj MultiVolumeImporter) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED MultiVolumeImporter_SOURCE_DIR) +if(NOT DEFINED ${extProjName}_SOURCE_DIR) #message(STATUS "${__indent}Adding project ${proj}") + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here if(NOT DEFINED git_protocol) - set(git_protocol "git") + set(git_protocol "git") endif() + set(${proj}_CMAKE_OPTIONS + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY "${git_protocol}://github.com/fedorov/MultiVolumeImporter.git") + set(${proj}_GIT_TAG "63883c9176c2ee1fe24803cbc2cc5268ab086aa8") ExternalProject_Add(${proj} - GIT_REPOSITORY "${git_protocol}://github.com/fedorov/MultiVolumeImporter.git" - GIT_TAG "63883c9176c2ee1fe24803cbc2cc5268ab086aa8" - "${slicer_external_update}" - SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" CMAKE_GENERATOR ${gen} CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS - ${MultiVolumeImporter_DEPENDENCIES} - ) - set(MultiVolumeImporter_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) else() - # The project is provided using MultiVolumeImporter_DIR, nevertheless since other project may depend on EMSegment, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${MultiVolumeImporter_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_NUMPY.cmake b/SuperBuild/External_NUMPY.cmake index b636bb36f2a63733dcffa308c0e5b250b494bbed..b09ecd6a62eb2dbd371d98c467c2b18457248196 100644 --- a/SuperBuild/External_NUMPY.cmake +++ b/SuperBuild/External_NUMPY.cmake @@ -1,27 +1,49 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName NUMPY) #The find_package known name +set(proj NUMPY) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + # Set dependency list -set(NUMPY_DEPENDENCIES python) +set(${proj}_DEPENDENCIES python) # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(NUMPY) -set(proj NUMPY) +SlicerMacroCheckExternalProjectDependency(${proj}) message(STATUS "${__${proj}_superbuild_message} - Building without Fortran compiler - Non-optimized code will be built !") - #message(STATUS "${__indent}Adding project ${proj}") set(numpy_URL http://svn.slicer.org/Slicer3-lib-mirrors/trunk/numpy-1.4.1.tar.gz) set(numpy_MD5 5c7b5349dc3161763f7f366ceb96516b) #------------------------------------------------------------------------------ -set(NUMPY_DIR "${CMAKE_BINARY_DIR}/${proj}") +set(${extProjName}_DIR "${CMAKE_BINARY_DIR}/${proj}") configure_file( SuperBuild/${proj}_environment.cmake.in @@ -46,7 +68,7 @@ ExternalProject_Add(${proj} DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR} SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/NUMPY BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/NUMPY - "${slicer_external_disable_update}" + "${cmakeversion_external_disable_update}" CONFIGURE_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/${proj}_configure_step.cmake BUILD_COMMAND ${CMAKE_COMMAND} @@ -54,8 +76,11 @@ ExternalProject_Add(${proj} INSTALL_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/${proj}_install_step.cmake PATCH_COMMAND ${CMAKE_COMMAND} - -DNUMPY_SRC_DIR=${Slicer_BINARY_DIR}/NUMPY + -DNUMPY_SRC_DIR=${${PROJECT_NAME}_BINARY_DIR}/NUMPY -P ${CMAKE_CURRENT_LIST_DIR}/${proj}_patch.cmake DEPENDS - ${NUMPY_DEPENDENCIES} + ${${proj}_DEPENDENCIES} ) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_OpenIGTLink.cmake b/SuperBuild/External_OpenIGTLink.cmake index efb100d0540ea28153ef0d226814cfc70b7c4f7b..505b4671a50db4ed46d646594aa3b947d0be170d 100644 --- a/SuperBuild/External_OpenIGTLink.cmake +++ b/SuperBuild/External_OpenIGTLink.cmake @@ -1,56 +1,102 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName OpenIGTLink) #The find_package known name +set(proj OpenIGTLink) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + # Set dependency list -set(OpenIGTLink_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(OpenIGTLink) -set(proj OpenIGTLink) - -# Set CMake OSX variable to pass down the external project -set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) -if(APPLE) - list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS - -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) -endif() +SlicerMacroCheckExternalProjectDependency(${proj}) + +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) + #message(STATUS "${__indent}Adding project ${proj}") -set(CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG) -if(CTEST_USE_LAUNCHERS) - set(CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + set(CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG) + if(CTEST_USE_LAUNCHERS) + set(CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG "-DCMAKE_PROJECT_OpenIGTLink_INCLUDE:FILEPATH=${CMAKE_ROOT}/Modules/CTestUseLaunchers.cmake") -endif() + endif() + ### --- Project specific additions here + -#message(STATUS "${__indent}Adding project ${proj}") - -ExternalProject_Add(${proj} - SVN_REPOSITORY "http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink" - SVN_REVISION -r "7701" - "${slicer_external_update}" - SOURCE_DIR OpenIGTLink - BINARY_DIR OpenIGTLink-build - CMAKE_GENERATOR ${gen} - CMAKE_ARGS - -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} - -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} - -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} - -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} - ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} - ${CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DBUILD_TESTING:BOOL=OFF - -DBUILD_SHARED_LIBS:BOOL=ON - -DOpenIGTLink_PROTOCOL_VERSION_2:BOOL=ON - INSTALL_COMMAND "" - DEPENDS - ${OpenIGTLink_DEPENDENCIES} + set(${proj}_CMAKE_OPTIONS + ${CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG} + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DBUILD_TESTING:BOOL=OFF + -DBUILD_SHARED_LIBS:BOOL=ON + -DOpenIGTLink_PROTOCOL_VERSION_2:BOOL=ON ) + ### --- End Project specific additions + ExternalProject_Add(${proj} + SVN_REPOSITORY "http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink" + SVN_REVISION -r "7701" + SOURCE_DIR ${proj} + BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" + CMAKE_GENERATOR ${gen} + CMAKE_ARGS + -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} + ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + ${${proj}_CMAKE_OPTIONS} + INSTALL_COMMAND "" + DEPENDS + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}-build) +else() + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") +endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) -set(OpenIGTLink_DIR ${CMAKE_BINARY_DIR}/OpenIGTLink-build) +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_OpenIGTLinkIF.cmake b/SuperBuild/External_OpenIGTLinkIF.cmake index f8bf5c963bd0b548cf8eafab68d97ec8992ffd6e..7850c4966053f85a22e7b12a0b1f861abf93d38b 100644 --- a/SuperBuild/External_OpenIGTLinkIF.cmake +++ b/SuperBuild/External_OpenIGTLinkIF.cmake @@ -1,43 +1,89 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName OpenIGTLinkIF) #The find_package known name +set(proj OpenIGTLinkIF) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED OpenIGTLinkIF_SOURCE_DIR AND NOT EXISTS ${OpenIGTLinkIF_SOURCE_DIR}) - message(FATAL_ERROR "OpenIGTLinkIF_SOURCE_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_SOURCE_DIR AND NOT EXISTS ${${extProjName}_SOURCE_DIR}) + message(FATAL_ERROR "${extProjName}_SOURCE_DIR variable is defined but corresponds to non-existing directory") endif() # Set dependency list -set(OpenIGTLinkIF_DEPENDENCIES OpenIGTLink) +set(${proj}_DEPENDENCIES OpenIGTLink) # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(OpenIGTLinkIF) -set(proj OpenIGTLinkIF) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED OpenIGTLinkIF_SOURCE_DIR) +if(NOT DEFINED ${extProjName}_SOURCE_DIR) #message(STATUS "${__indent}Adding project ${proj}") + + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here + set(${proj}_CMAKE_OPTIONS + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY "${git_protocol}://github.com/Slicer/OpenIGTLinkIF.git") + set(${proj}_GIT_TAG "8330b769cc8c607067134296d577b64ae7c92b87") ExternalProject_Add(${proj} + #GIT_REPOSITORY ${${proj}_REPOSITORY} + #GIT_TAG ${${proj}_GIT_TAG} SVN_REPOSITORY "http://svn.na-mic.org/NAMICSandBox/trunk/IGTLoadableModules/QtModules/OpenIGTLinkIF/" SVN_REVISION -r "8024" - "${slicer_external_update}" - #GIT_REPOSITORY "${git_protocol}://github.com/Slicer/OpenIGTLinkIF.git" - #GIT_TAG "8330b769cc8c607067134296d577b64ae7c92b87" - SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} + SOURCE_DIR ${proj} BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" CMAKE_GENERATOR ${gen} CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS - ${OpenIGTLinkIF_DEPENDENCIES} - ) - set(OpenIGTLinkIF_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) else() - # The project is provided using OpenIGTLinkIF_SOURCE_DIR, nevertheless since other project may depend on OpenIGTLinkIF, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${OpenIGTLinkIF_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_PCRE.cmake b/SuperBuild/External_PCRE.cmake index ab3b31b9f539cd45eb6d019bd8a351f8fdbdf97f..514781123e39b0eeedd693234ef4ba81062396f7 100644 --- a/SuperBuild/External_PCRE.cmake +++ b/SuperBuild/External_PCRE.cmake @@ -1,21 +1,40 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName PCRE) #The find_package known name +set(proj PCRE) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED PCRE_DIR AND NOT EXISTS ${PCRE_DIR}) - message(FATAL_ERROR "PCRE_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") endif() # Set dependency list -set(PCRE_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(PCRE) +SlicerMacroCheckExternalProjectDependency(${proj}) # # PCRE (Perl Compatible Regular Expressions) @@ -32,9 +51,12 @@ configure_file( @ONLY) set(pcre_CONFIGURE_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/pcre_configure_step.cmake) -ExternalProject_add(PCRE +ExternalProject_Add(${proj} URL http://downloads.sourceforge.net/project/pcre/pcre/8.12/pcre-8.12.tar.gz URL_MD5 fa69e4c5d8971544acd71d1f10d59193 - "${slicer_external_disable_update}" + "${cmakeversion_external_disable_update}" CONFIGURE_COMMAND ${pcre_CONFIGURE_COMMAND} ) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_SciPy.cmake b/SuperBuild/External_SciPy.cmake index 64bb29412086aa39844b0263799e7336f2d97005..4316f7c0e1678334a9d8dd1fd8e596710321d24b 100644 --- a/SuperBuild/External_SciPy.cmake +++ b/SuperBuild/External_SciPy.cmake @@ -1,27 +1,53 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName SciPy) #The find_package known name +set(proj SciPy) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + # Set dependency list -set(SciPy_DEPENDENCIES NUMPY) +set(${proj}_DEPENDENCIES NUMPY) # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(SciPy) -set(proj SciPy) +SlicerMacroCheckExternalProjectDependency(${proj}) #message(STATUS "${__indent}Adding project ${proj}") ExternalProject_Add(${proj} SVN_REPOSITORY "http://svn.scipy.org/svn/scipy/branches/0.7.x" - "${slicer_external_update}" + "${cmakeversion_external_update}" SOURCE_DIR python/scipy CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS - ${SciPy_DEPENDENCIES} + ${${proj}_DEPENDENCIES} ) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_SimpleITK.cmake b/SuperBuild/External_SimpleITK.cmake index 551aa60f99366f11e69c5d28374dab856b04e959..362a4d58f1512f9cb0c591ddd2455c73ced0d096 100644 --- a/SuperBuild/External_SimpleITK.cmake +++ b/SuperBuild/External_SimpleITK.cmake @@ -1,80 +1,133 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName SimpleITK) #The find_package known name +set(proj SimpleITK) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED SimpleITK_DIR AND NOT EXISTS ${SimpleITK_DIR}) - message(FATAL_ERROR "SimpleITK_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") endif() # Set dependency list -set(SimpleITK_DEPENDENCIES ITKv4 Swig python) +set(${proj}_DEPENDENCIES ITKv4 Swig python) # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(SimpleITK) - -# -# SimpleITK externalBuild -# -include(ExternalProject) - -if(APPLE) - set(SIMPLEITK_PYTHON_ARGS - -DPYTHON_EXECUTABLE:PATH=${slicer_PYTHON_EXECUTABLE} - -DPYTHON_FRAMEWORKS:PATH=${slicer_PYTHON_FRAMEWORK} - -DPYTHON_LIBRARY:FILEPATH=${slicer_PYTHON_LIBRARY} - -DPYTHON_INCLUDE_DIR:PATH=${slicer_PYTHON_INCLUDE} - ) -else() - set(SIMPLEITK_PYTHON_ARGS - -DPYTHON_EXECUTABLE:PATH=${slicer_PYTHON_EXECUTABLE} - -DPYTHON_LIBRARY:FILEPATH=${slicer_PYTHON_LIBRARY} - -DPYTHON_INCLUDE_DIR:PATH=${slicer_PYTHON_INCLUDE} - ) -endif() +SlicerMacroCheckExternalProjectDependency(${proj}) + +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) + #message(STATUS "${__indent}Adding project ${proj}") + + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here + if(APPLE) + set(SIMPLEITK_PYTHON_ARGS + -DPYTHON_EXECUTABLE:PATH=${slicer_PYTHON_EXECUTABLE} + -DPYTHON_FRAMEWORKS:PATH=${slicer_PYTHON_FRAMEWORK} + -DPYTHON_LIBRARY:FILEPATH=${slicer_PYTHON_LIBRARY} + -DPYTHON_INCLUDE_DIR:PATH=${slicer_PYTHON_INCLUDE} + ) + else() + set(SIMPLEITK_PYTHON_ARGS + -DPYTHON_EXECUTABLE:PATH=${slicer_PYTHON_EXECUTABLE} + -DPYTHON_LIBRARY:FILEPATH=${slicer_PYTHON_LIBRARY} + -DPYTHON_INCLUDE_DIR:PATH=${slicer_PYTHON_INCLUDE} + ) + endif() -configure_file(SuperBuild/SimpleITK_install_step.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/SimpleITK_install_step.cmake - @ONLY) - -set(SimpleITK_INSTALL_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/SimpleITK_install_step.cmake) - - -ExternalProject_add(SimpleITK - SOURCE_DIR SimpleITK - BINARY_DIR SimpleITK-build - GIT_REPOSITORY http://itk.org/SimpleITK.git - GIT_TAG c9d890337f1b582acb0482e16c06aa62f3af0886 - "${slicer_external_update}" - CMAKE_ARGS - -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} - -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} - -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} - -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} - ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + configure_file(SuperBuild/SimpleITK_install_step.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/SimpleITK_install_step.cmake + @ONLY) + + set(SimpleITK_INSTALL_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/SimpleITK_install_step.cmake) + + set(${proj}_CMAKE_OPTIONS -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - # SimpleITK does not work with shared libs turned on - -DBUILD_SHARED_LIBS:BOOL=OFF - -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR} - -DITK_DIR:PATH=${ITK_DIR} - -DBUILD_EXAMPLES:BOOL=OFF - -DBUILD_TESTING:BOOL=OFF - -DBUILD_DOXYGEN:BOOL=OFF - -DWRAP_PYTHON:BOOL=ON - -DWRAP_TCL:BOOL=OFF - -DWRAP_JAVA:BOOL=OFF - -DWRAP_RUBY:BOOL=OFF - -DWRAP_LUA:BOOL=OFF - -DWRAP_CSHARP:BOOL=OFF - -DWRAP_R:BOOL=OFF - ${SIMPLEITK_PYTHON_ARGS} - -DSWIG_EXECUTABLE:PATH=${SWIG_EXECUTABLE} - # - INSTALL_COMMAND ${SimpleITK_INSTALL_COMMAND} - # - DEPENDS ${SimpleITK_DEPENDENCIES} + # SimpleITK does not work with shared libs turned on + -DBUILD_SHARED_LIBS:BOOL=OFF + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR} + -DITK_DIR:PATH=${ITK_DIR} + -DBUILD_EXAMPLES:BOOL=OFF + -DBUILD_TESTING:BOOL=OFF + -DBUILD_DOXYGEN:BOOL=OFF + -DWRAP_PYTHON:BOOL=ON + -DWRAP_TCL:BOOL=OFF + -DWRAP_JAVA:BOOL=OFF + -DWRAP_RUBY:BOOL=OFF + -DWRAP_LUA:BOOL=OFF + -DWRAP_CSHARP:BOOL=OFF + -DWRAP_R:BOOL=OFF + ${SIMPLEITK_PYTHON_ARGS} + -DSWIG_EXECUTABLE:PATH=${SWIG_EXECUTABLE} + # + ) + + ### --- End Project specific additions + set(${proj}_REPOSITORY http://itk.org/SimpleITK.git) + set(${proj}_GIT_TAG c9d890337f1b582acb0482e16c06aa62f3af0886) + ExternalProject_Add(${proj} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} + BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" + CMAKE_GENERATOR ${gen} + CMAKE_ARGS + -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} + ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + ${${proj}_CMAKE_OPTIONS} + INSTALL_COMMAND ${SimpleITK_INSTALL_COMMAND} + DEPENDS + ${${proj}_DEPENDENCIES} ) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}-build) +else() + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") +endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) + diff --git a/SuperBuild/External_SlicerExecutionModel.cmake b/SuperBuild/External_SlicerExecutionModel.cmake index 526f9f827ab6ba8d43dc8c8346c8c926fc3a8092..83f3832adc934d052c0cfc9e6d35255bcf2cee2f 100644 --- a/SuperBuild/External_SlicerExecutionModel.cmake +++ b/SuperBuild/External_SlicerExecutionModel.cmake @@ -1,24 +1,42 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName SlicerExecutionModel) #The find_package known name +set(proj SlicerExecutionModel) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED SlicerExecutionModel_DIR AND NOT EXISTS ${SlicerExecutionModel_DIR}) - message(FATAL_ERROR "SlicerExecutionModel_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") endif() # Set dependency list -set(SlicerExecutionModel_DEPENDENCIES ${ITK_EXTERNAL_NAME}) +set(${proj}_DEPENDENCIES ${ITK_EXTERNAL_NAME}) # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(SlicerExecutionModel) -set(proj SlicerExecutionModel) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED SlicerExecutionModel_DIR) +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) #message(STATUS "${__indent}Adding project ${proj}") # Set CMake OSX variable to pass down the external project @@ -31,43 +49,61 @@ if(NOT DEFINED SlicerExecutionModel_DIR) endif() if(NOT DEFINED git_protocol) - set(git_protocol "git") + set(git_protocol "git") endif() + set(${proj}_CMAKE_OPTIONS + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DBUILD_TESTING:BOOL=OFF + -DITK_DIR:PATH=${ITK_DIR} + -DSlicerExecutionModel_LIBRARY_PROPERTIES:STRING=${${PROJECT_NAME}_LIBRARY_PROPERTIES} + -DSlicerExecutionModel_INSTALL_BIN_DIR:PATH=${${PROJECT_NAME}_INSTALL_LIB_DIR} + -DSlicerExecutionModel_INSTALL_LIB_DIR:PATH=${${PROJECT_NAME}_INSTALL_LIB_DIR} + #-DSlicerExecutionModel_INSTALL_SHARE_DIR:PATH=${${PROJECT_NAME}_INSTALL_ROOT}share/${SlicerExecutionModel} + -DSlicerExecutionModel_INSTALL_NO_DEVELOPMENT:BOOL=${${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT} + -DSlicerExecutionModel_DEFAULT_CLI_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_BINARY_DIR}/${${PROJECT_NAME}_BINARY_INNER_SUBDIR}/${${PROJECT_NAME}_CLIMODULES_BIN_DIR} + -DSlicerExecutionModel_DEFAULT_CLI_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_BINARY_DIR}/${${PROJECT_NAME}_BINARY_INNER_SUBDIR}/${${PROJECT_NAME}_CLIMODULES_LIB_DIR} + -DSlicerExecutionModel_DEFAULT_CLI_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_BINARY_DIR}/${${PROJECT_NAME}_BINARY_INNER_SUBDIR}/${${PROJECT_NAME}_CLIMODULES_LIB_DIR} + -DSlicerExecutionModel_DEFAULT_CLI_INSTALL_RUNTIME_DESTINATION:STRING=${${PROJECT_NAME}_INSTALL_CLIMODULES_BIN_DIR} + -DSlicerExecutionModel_DEFAULT_CLI_INSTALL_LIBRARY_DESTINATION:STRING=${${PROJECT_NAME}_INSTALL_CLIMODULES_LIB_DIR} + -DSlicerExecutionModel_DEFAULT_CLI_INSTALL_ARCHIVE_DESTINATION:STRING=${${PROJECT_NAME}_INSTALL_CLIMODULES_LIB_DIR} + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY "${git_protocol}://github.com/Slicer/SlicerExecutionModel.git" ) + set(${proj}_GIT_TAG "2986286df7819b4bd2c0b7e2d25efe7fd23ff51f" ) ExternalProject_Add(${proj} - GIT_REPOSITORY "${git_protocol}://github.com/Slicer/SlicerExecutionModel.git" - GIT_TAG "2986286df7819b4bd2c0b7e2d25efe7fd23ff51f" - "${slicer_external_update}" - SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" CMAKE_GENERATOR ${gen} CMAKE_ARGS -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} - -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} # Unused + -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DBUILD_TESTING:BOOL=OFF - -DITK_DIR:PATH=${ITK_DIR} - -DSlicerExecutionModel_LIBRARY_PROPERTIES:STRING=${Slicer_LIBRARY_PROPERTIES} - -DSlicerExecutionModel_INSTALL_BIN_DIR:PATH=${Slicer_INSTALL_LIB_DIR} - -DSlicerExecutionModel_INSTALL_LIB_DIR:PATH=${Slicer_INSTALL_LIB_DIR} - #-DSlicerExecutionModel_INSTALL_SHARE_DIR:PATH=${Slicer_INSTALL_ROOT}share/${SlicerExecutionModel} - -DSlicerExecutionModel_INSTALL_NO_DEVELOPMENT:BOOL=${Slicer_INSTALL_NO_DEVELOPMENT} - -DSlicerExecutionModel_DEFAULT_CLI_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_BINARY_DIR}/${Slicer_BINARY_INNER_SUBDIR}/${Slicer_CLIMODULES_BIN_DIR} - -DSlicerExecutionModel_DEFAULT_CLI_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_BINARY_DIR}/${Slicer_BINARY_INNER_SUBDIR}/${Slicer_CLIMODULES_LIB_DIR} - -DSlicerExecutionModel_DEFAULT_CLI_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_BINARY_DIR}/${Slicer_BINARY_INNER_SUBDIR}/${Slicer_CLIMODULES_LIB_DIR} - -DSlicerExecutionModel_DEFAULT_CLI_INSTALL_RUNTIME_DESTINATION:STRING=${Slicer_INSTALL_CLIMODULES_BIN_DIR} - -DSlicerExecutionModel_DEFAULT_CLI_INSTALL_LIBRARY_DESTINATION:STRING=${Slicer_INSTALL_CLIMODULES_LIB_DIR} - -DSlicerExecutionModel_DEFAULT_CLI_INSTALL_ARCHIVE_DESTINATION:STRING=${Slicer_INSTALL_CLIMODULES_LIB_DIR} + ${${proj}_CMAKE_OPTIONS} INSTALL_COMMAND "" DEPENDS - ${SlicerExecutionModel_DEPENDENCIES} - ) - set(SlicerExecutionModel_DIR ${CMAKE_BINARY_DIR}/${proj}-build) + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}-build) else() - # The project is provided using SlicerExecutionModel_DIR, nevertheless since other project may depend on SlicerExecutionModel, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${SlicerExecutionModel_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_Swig.cmake b/SuperBuild/External_Swig.cmake index 7821430ee48d28616b756e763cf7e2ae8325998d..2f50cb946db0c81febc47f15d3275e5f8d278112 100644 --- a/SuperBuild/External_Swig.cmake +++ b/SuperBuild/External_Swig.cmake @@ -1,25 +1,44 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName Swig) #The find_package known name +set(proj Swig) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED Swig_DIR AND NOT EXISTS ${Swig_DIR}) - message(FATAL_ERROR "Swig_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory") endif() set( TARGET_SWIG_VERSION 2.0.8 ) if(NOT SWIG_DIR) if(WIN32) # swig.exe available as pre-built binary on Windows: - ExternalProject_Add(Swig + ExternalProject_Add(${proj} URL http://prdownloads.sourceforge.net/swig/swigwin-${TARGET_SWIG_VERSION}.zip URL_MD5 4ab8064b1a8894c8577ef9d0fb2523c8 SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/swigwin-${TARGET_SWIG_VERSION} - "${slicer_external_disable_update}" + "${cmakeversion_external_disable_update}" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" @@ -30,10 +49,10 @@ if(NOT SWIG_DIR) set(Swig_DEPEND Swig) else() # Set dependency list - set(Swig_DEPENDENCIES "PCRE") + set(${proj}_DEPENDENCIES "PCRE") # Include dependent projects if any - SlicerMacroCheckExternalProjectDependency(Swig) + SlicerMacroCheckExternalProjectDependency(${proj}) # # SWIG # @@ -54,7 +73,7 @@ if(NOT SWIG_DIR) @ONLY) set ( swig_CONFIGURE_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/swig_configure_step.cmake ) - ExternalProject_add(Swig + ExternalProject_Add(${proj} URL http://prdownloads.sourceforge.net/swig/swig-${TARGET_SWIG_VERSION}.tar.gz URL_MD5 69f917e870efc0712c06ab53217b28d1 CONFIGURE_COMMAND ${swig_CONFIGURE_COMMAND} @@ -66,3 +85,6 @@ if(NOT SWIG_DIR) set(Swig_DEPEND Swig) endif() endif() + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_Teem.cmake b/SuperBuild/External_Teem.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a51812f2012dca59aab84f5ccc35f17ef240881f --- /dev/null +++ b/SuperBuild/External_Teem.cmake @@ -0,0 +1,130 @@ + +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. +get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) +if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) + return() +endif() +set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) + +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName Teem) #The find_package known name +set(proj Teem) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + +# Set dependency list +set(${proj}_DEPENDENCIES VTK) + +# Include dependent projects if any +SlicerMacroCheckExternalProjectDependency(${proj}) + +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) + #message(STATUS "${__indent}Adding project ${proj}") + + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + set(CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG) + if(CTEST_USE_LAUNCHERS) + set(CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG + "-DCMAKE_PROJECT_Teem_INCLUDE:FILEPATH=${CMAKE_ROOT}/Modules/CTestUseLaunchers.cmake") + endif() + + ### --- Project specific additions here + + if(WIN32) + set(${proj}_ZLIB_LIBRARY ${VTK_DIR}/bin/${CMAKE_CFG_INTDIR}/vtkzlib.lib) + set(${proj}_PNG_LIBRARY ${VTK_DIR}/bin/${CMAKE_CFG_INTDIR}/vtkpng.lib) + elseif(APPLE) + set(${proj}_ZLIB_LIBRARY ${VTK_DIR}/bin/libvtkzlib.dylib) + set(${proj}_PNG_LIBRARY ${VTK_DIR}/bin/libvtkpng.dylib) + else() + set(${proj}_ZLIB_LIBRARY ${VTK_DIR}/bin/libvtkzlib.so) + set(${proj}_PNG_LIBRARY ${VTK_DIR}/bin/libvtkpng.so) + endif() + + set(${proj}_CMAKE_OPTIONS + -DTeem_USE_LIB_INSTALL_SUBDIR:BOOL=ON + -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF + -DTeem_PTHREAD:BOOL=OFF + -DTeem_BZIP2:BOOL=OFF + -DTeem_ZLIB:BOOL=ON + -DTeem_PNG:BOOL=ON + -DTeem_VTK_MANGLE:BOOL=ON + -DTeem_VTK_TOOLKITS_IPATH:FILEPATH=${VTK_DIR} + -DZLIB_INCLUDE_DIR:PATH=${VTK_SOURCE_DIR}/Utilities + -DTeem_VTK_ZLIB_MANGLE_IPATH:PATH=${VTK_SOURCE_DIR}/Utilities/vtkzlib + -DTeem_ZLIB_DLLCONF_IPATH:PATH=${VTK_DIR}/Utilities + -DZLIB_LIBRARY:FILEPATH=${${proj}_ZLIB_LIBRARY} + -DPNG_PNG_INCLUDE_DIR:PATH=${VTK_SOURCE_DIR}/Utilities/vtkpng + -DTeem_PNG_DLLCONF_IPATH:PATH=${VTK_DIR}/Utilities + -DPNG_LIBRARY:FILEPATH=${${proj}_PNG_LIBRARY} + ) + ### --- End Project specific additions + set(${proj}_URL http://svn.slicer.org/Slicer3-lib-mirrors/trunk/teem-1.10.0-src.tar.gz) + set(${proj}_MD5 efe219575adc89f6470994154d86c05b) + ExternalProject_Add(${proj} + URL ${${proj}_URL} + URL_MD5 ${${proj}_MD5} + DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR} + SOURCE_DIR ${proj} + BINARY_DIR ${proj}-build + INSTALL_COMMAND "" + "${cmakeversion_external_update}" + CMAKE_GENERATOR ${gen} + CMAKE_ARGS + -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} + # Not needed -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} + ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DBUILD_TESTING:BOOL=OFF + -DBUILD_SHARED_LIBS:BOOL=ON + ${CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG} + ${${proj}_CMAKE_OPTIONS} + DEPENDS + ${${proj}_DEPENDENCIES} + ) + set(${proj}_DIR ${CMAKE_BINARY_DIR}/${proj}-build) +else() + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") +endif() + +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_VTK.cmake b/SuperBuild/External_VTK.cmake index 3dabd8dabb3a52fbd5e0207a0ad3aa4638ed72af..d9de1f27e41d6bc88ce2abf2180b72d9c0a3307a 100644 --- a/SuperBuild/External_VTK.cmake +++ b/SuperBuild/External_VTK.cmake @@ -1,41 +1,71 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName VTK) #The find_package known name +set(proj VTK) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED VTK_DIR AND NOT EXISTS ${VTK_DIR}) - message(FATAL_ERROR "VTK_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") endif() -if(DEFINED VTK_SOURCE_DIR AND NOT EXISTS ${VTK_SOURCE_DIR}) - message(FATAL_ERROR "VTK_SOURCE_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_SOURCE_DIR AND NOT EXISTS ${${extProjName}_SOURCE_DIR}) + message(FATAL_ERROR "${extProjName}_SOURCE_DIR variable is defined but corresponds to non-existing directory") endif() # Set dependency list -set(VTK_DEPENDENCIES "") -if (Slicer_USE_PYTHONQT) - list(APPEND VTK_DEPENDENCIES python) +set(${proj}_DEPENDENCIES "") +if (${PROJECT_NAME}_USE_PYTHONQT) + list(APPEND ${proj}_DEPENDENCIES python) endif() # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(VTK) -set(proj VTK) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED VTK_DIR OR NOT DEFINED VTK_SOURCE_DIR) +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) +#OR NOT DEFINED ${extProjName}_SOURCE_DIR) #message(STATUS "${__indent}Adding project ${proj}") + + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here set(VTK_WRAP_TCL OFF) set(VTK_WRAP_PYTHON OFF) - if (Slicer_USE_PYTHONQT) + if (${PROJECT_NAME}_USE_PYTHONQT) set(VTK_WRAP_PYTHON ON) endif() set(VTK_PYTHON_ARGS) - if(Slicer_USE_PYTHONQT) + if(${PROJECT_NAME}_USE_PYTHONQT) set(VTK_PYTHON_ARGS -DVTK_INSTALL_PYTHON_USING_CMAKE:BOOL=ON -DPYTHON_EXECUTABLE:PATH=${slicer_PYTHON_EXECUTABLE} @@ -68,7 +98,7 @@ if(NOT DEFINED VTK_DIR OR NOT DEFINED VTK_SOURCE_DIR) endif() # Disable Tk when Python wrapping is enabled - if (Slicer_USE_PYTHONQT) + if (${PROJECT_NAME}_USE_PYTHONQT) list(APPEND VTK_QT_ARGS -DVTK_USE_TK:BOOL=OFF) endif() @@ -117,14 +147,6 @@ if(NOT DEFINED VTK_DIR OR NOT DEFINED VTK_SOURCE_DIR) -P ${CMAKE_CURRENT_BINARY_DIR}/VTK_build_step.cmake) endif() - # Set CMake OSX variable to pass down the external project - set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) - if(APPLE) - list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS - -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) - endif() set(${CMAKE_PROJECT_NAME}_${proj}_GIT_REPOSITORY "github.com/Slicer/VTK.git" CACHE STRING "Repository from which to get VTK" FORCE) set(${CMAKE_PROJECT_NAME}_${proj}_GIT_TAG "03ddda8cd503b957268fee138c7b57465e5842a4" CACHE STRING "VTK git tag to use" FORCE) @@ -132,48 +154,64 @@ if(NOT DEFINED VTK_DIR OR NOT DEFINED VTK_SOURCE_DIR) mark_as_advanced(${CMAKE_PROJECT_NAME}_${proj}_GIT_REPOSITORY ${CMAKE_PROJECT_NAME}_${proj}_GIT_TAG) if(NOT DEFINED git_protocol) - set(git_protocol "git") + set(git_protocol "git") endif() - ExternalProject_Add(${proj} - SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} - BINARY_DIR ${proj}-build - GIT_REPOSITORY "${git_protocol}://${${CMAKE_PROJECT_NAME}_${proj}_GIT_REPOSITORY}" - GIT_TAG ${${CMAKE_PROJECT_NAME}_${proj}_GIT_TAG} - "${slicer_external_update}" - CMAKE_GENERATOR ${gen} - ${CUSTOM_BUILD_COMMAND} - CMAKE_ARGS - -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} - -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} - -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} - -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} - ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + set(${proj}_CMAKE_OPTIONS -DBUILD_TESTING:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS:BOOL=ON -DVTK_USE_PARALLEL:BOOL=ON - -DVTK_DEBUG_LEAKS:BOOL=${Slicer_USE_VTK_DEBUG_LEAKS} + -DVTK_DEBUG_LEAKS:BOOL=${${PROJECT_NAME}_USE_VTK_DEBUG_LEAKS} -DVTK_LEGACY_REMOVE:BOOL=ON -DVTK_WRAP_TCL:BOOL=${VTK_WRAP_TCL} #-DVTK_USE_RPATH:BOOL=ON # Unused ${VTK_TCL_ARGS} -DVTK_WRAP_PYTHON:BOOL=${VTK_WRAP_PYTHON} - -DVTK_INSTALL_LIB_DIR:PATH=${Slicer_INSTALL_LIB_DIR} + -DVTK_INSTALL_LIB_DIR:PATH=${${PROJECT_NAME}_INSTALL_LIB_DIR} ${VTK_PYTHON_ARGS} ${VTK_QT_ARGS} ${VTK_MAC_ARGS} + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY "${git_protocol}://${${CMAKE_PROJECT_NAME}_${proj}_GIT_REPOSITORY}" ) + set(${proj}_GIT_TAG ${${CMAKE_PROJECT_NAME}_${proj}_GIT_TAG} ) + ExternalProject_Add(${proj} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} + BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" + CMAKE_GENERATOR ${gen} + ${CUSTOM_BUILD_COMMAND} + CMAKE_ARGS + -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} + ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + ${${proj}_CMAKE_OPTIONS} INSTALL_COMMAND "" DEPENDS - ${VTK_DEPENDENCIES} + ${${proj}_DEPENDENCIES} ) - set(VTK_DIR ${CMAKE_BINARY_DIR}/${proj}-build) - set(VTK_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) - + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}-build) + set(${extProjName}_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}) else() - # The project is provided using VTK_DIR and VTK_SOURCE_DIR, nevertheless since other - # project may depend on VTK, let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${VTK_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_cmcurl.cmake b/SuperBuild/External_cmcurl.cmake index 2bbdb1ba090f79ce8b0b73e0c5841c9ea540d0e6..2bbac15179af7e58444850cb5f1cb424bf07938e 100644 --- a/SuperBuild/External_cmcurl.cmake +++ b/SuperBuild/External_cmcurl.cmake @@ -1,49 +1,94 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName cmcurl) #The find_package known name +set(proj cmcurl) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + # Set dependency list -set(cmcurl_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(cmcurl) -set(proj cmcurl) - -# Set CMake OSX variable to pass down the external project -set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) -if(APPLE) - list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS - -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) -endif() +SlicerMacroCheckExternalProjectDependency(${proj}) + +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) + #message(STATUS "${__indent}Adding project ${proj}") + + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() -#message(STATUS "${__indent}Adding project ${proj}") -ExternalProject_Add(${proj} - SVN_REPOSITORY "http://svn.slicer.org/Slicer3-lib-mirrors/trunk/cmcurl" - SVN_REVISION -r "185" - "${slicer_external_update}" - SOURCE_DIR cmcurl - BINARY_DIR cmcurl-build - CMAKE_GENERATOR ${gen} - CMAKE_ARGS - #Not needed -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} - #Not needed -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} - -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} - -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} - ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DSLICERLIBCURL_TESTING:BOOL=OFF - #Not used -DBUILD_TESTING:BOOL=OFF - -DBUILD_SHARED_LIBS:BOOL=ON - INSTALL_COMMAND "" - DEPENDS - ${cmcurl_DEPENDENCIES} + ### --- Project specific additions here + set(${proj}_CMAKE_OPTIONS + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DSLICERLIBCURL_TESTING:BOOL=OFF + #Not used -DBUILD_TESTING:BOOL=OFF + -DBUILD_SHARED_LIBS:BOOL=ON ) + ### --- End Project specific additions + ExternalProject_Add(${proj} + SVN_REPOSITORY "http://svn.slicer.org/Slicer3-lib-mirrors/trunk/cmcurl" + SVN_REVISION -r "185" + SOURCE_DIR ${proj} + BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" + CMAKE_GENERATOR ${gen} + CMAKE_ARGS + #Not needed -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} + #Not needed -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} + ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + ${${proj}_CMAKE_OPTIONS} + INSTALL_COMMAND "" + DEPENDS + ${${proj}_DEPENDENCIES} + ) + set(SLICERLIBCURL_DIR ${CMAKE_BINARY_DIR}/${proj}-build) +else() + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") +endif() -set(SLICERLIBCURL_DIR ${CMAKE_BINARY_DIR}/cmcurl-build) +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_incrTcl.cmake b/SuperBuild/External_incrTcl.cmake index 41750a08c3c2dfe1203087f267fb2185d6ce1d2a..628313dd7563ed18f1197e9d42f73aca000e2594 100644 --- a/SuperBuild/External_incrTcl.cmake +++ b/SuperBuild/External_incrTcl.cmake @@ -1,17 +1,40 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName incrTcl) #The find_package known name +set(proj incrTcl) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + # Set dependency list -set(incrTcl_DEPENDENCIES tcl tk) +set(${proj}_DEPENDENCIES tcl tk) # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(incrTcl) -set(proj incrTcl) +SlicerMacroCheckExternalProjectDependency(${proj}) #message(STATUS "${__indent}Adding project ${proj}") @@ -57,7 +80,7 @@ if(NOT WIN32) ExternalProject_Add(${proj} SVN_REPOSITORY ${incrTcl_SVN_REPOSITORY} SVN_REVISION ${incrTcl_SVN_REVISION} - "${slicer_external_disable_update}" + "${cmakeversion_external_disable_update}" SOURCE_DIR tcl/incrTcl BUILD_IN_SOURCE ${incrTcl_BUILD_IN_SOURCE} PATCH_COMMAND ${incrTcl_PATCH_COMMAND} @@ -65,7 +88,7 @@ if(NOT WIN32) BUILD_COMMAND ${incrTcl_BUILD_COMMAND} INSTALL_COMMAND ${incrTcl_INSTALL_COMMAND} DEPENDS - ${incrTcl_DEPENDENCIES} + ${${proj}_DEPENDENCIES} ) ExternalProject_Add_Step(${proj} CHMOD_incrTcl_configure @@ -75,3 +98,5 @@ if(NOT WIN32) ) endif() +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_jqPlot.cmake b/SuperBuild/External_jqPlot.cmake index 3c13ba168aa57e0ea6b5a0caa30c562ff5e2939e..ea0b56b4471805b23bc3bec57ec4923e6d739ad9 100644 --- a/SuperBuild/External_jqPlot.cmake +++ b/SuperBuild/External_jqPlot.cmake @@ -1,39 +1,85 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName jqPlot) #The find_package known name +set(proj jqPlot) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + # Set dependency list -set(jqPlot_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(jqPlot) -set(proj jqPlot) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED jqPlot_DIR) +if(NOT DEFINED ${extProjName}_DIR) #message(STATUS "${__indent}Adding project ${proj}") + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here + set(${proj}_CMAKE_OPTIONS + ) + ### --- End Project specific additions ExternalProject_Add(${proj} URL http://cloud.github.com/downloads/Slicer/jqplot/jquery.jqplot.1.0.4r1115.tar.gz URL_MD5 5c5d73730145c3963f09e1d3ca355580 - "${slicer_external_update}" - SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/jqPlot - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/jqPlot-build + SOURCE_DIR ${proj} + BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS - ${jqPlot_DEPENDENCIES} - ) - set(jqPlot_DIR ${CMAKE_BINARY_DIR}/${proj}) - mark_as_advanced(jqPlot_DIR) - + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}) + mark_as_advanced(${extProjName}_DIR) else() - # The project is provided using jqPlot_DIR, nevertheless since other project may depend on jqPlot, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${jqPlot_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_python.cmake b/SuperBuild/External_python.cmake index 8ac0614acd265bd5e10538bca9f4c4fe2c965883..68f41bbaca903bbd7da861d3aeced030fd5b4fd4 100644 --- a/SuperBuild/External_python.cmake +++ b/SuperBuild/External_python.cmake @@ -1,14 +1,38 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName python) #The find_package known name +set(proj python) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + # Set dependency list set(python_DEPENDENCIES CTKAPPLAUNCHER) -if(Slicer_USE_PYTHONQT_WITH_TCL) +if(${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL) if(WIN32) list(APPEND python_DEPENDENCIES tcl) else() @@ -17,11 +41,22 @@ if(Slicer_USE_PYTHONQT_WITH_TCL) endif() # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(python) -set(proj python) +SlicerMacroCheckExternalProjectDependency(${proj}) +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) #message(STATUS "${__indent}Adding project ${proj}") +# Set CMake OSX variable to pass down the external project +set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) +if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) +endif() + +### --- Project specific additions here + set(python_base ${CMAKE_CURRENT_BINARY_DIR}/${proj}) set(python_build ${CMAKE_CURRENT_BINARY_DIR}/${proj}-build) # @@ -58,5 +93,10 @@ endif() #message(STATUS "slicer_PYTHON_INCLUDE:${slicer_PYTHON_INCLUDE}") #message(STATUS "slicer_PYTHON_LIBRARY:${slicer_PYTHON_LIBRARY}") #message(STATUS "slicer_PYTHON_EXECUTABLE:${slicer_PYTHON_EXECUTABLE}") +else() +endif() +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_python_unix.cmake b/SuperBuild/External_python_unix.cmake index c339821dd451c56104609df13740a8719cae2ed9..ac920f99a3055fd01453d71895d722f921690976 100644 --- a/SuperBuild/External_python_unix.cmake +++ b/SuperBuild/External_python_unix.cmake @@ -6,8 +6,6 @@ endif() set(python_SOURCE_DIR python) set(python_BUILD_IN_SOURCE 1) - - # Set slicer_PYTHON_INCLUDE, slicer_PYTHON_LIBRARY and slicer_PYTHON_EXECUTABLE variables set(python_IMPORT_SUFFIX so) if(APPLE) @@ -48,7 +46,7 @@ set(python_INSTALL_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/pytho ExternalProject_Add(${proj} URL ${python_URL} URL_MD5 ${python_MD5} - "${slicer_external_disable_update}" + "${cmakeversion_external_disable_update}" DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR} SOURCE_DIR ${python_SOURCE_DIR} BUILD_IN_SOURCE ${python_BUILD_IN_SOURCE} diff --git a/SuperBuild/External_python_win.cmake b/SuperBuild/External_python_win.cmake index 2b1428e0331c302dd3a72f4b433f1ee9b042a65e..81f42350191984407980bb687158b734f7f5214b 100644 --- a/SuperBuild/External_python_win.cmake +++ b/SuperBuild/External_python_win.cmake @@ -38,7 +38,7 @@ endif() # Point the tkinter build file to the slicer tcl-build set(python_PATCH_COMMAND "") -if(Slicer_USE_PYTHONQT_WITH_TCL) +if(${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL) set(python_tkinter ${python_base}/pyproject.vsprops) # The following if statement is specific to VS2010 if("${MSVC_VERSION}" VERSION_GREATER "1599") @@ -85,7 +85,7 @@ set_ep_build_command_args(select) ExternalProject_Add(${proj} URL ${python_URL} URL_MD5 ${python_MD5} - "${slicer_external_disable_update}" + "${cmakeversion_external_disable_update}" DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR} SOURCE_DIR python-build PATCH_COMMAND ${python_PATCH_COMMAND} @@ -104,7 +104,7 @@ build_python_target(w9xpopen Build_kill_python) build_python_target(pythoncore Build_w9xpopen) build_python_target(_socket Build_pythoncore) -if(Slicer_USE_PYTHONQT_WITH_TCL) +if(${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL) build_python_target(_tkinter Build__socket) build_python_target(_testcapi Build__tkinter) else() @@ -154,7 +154,7 @@ ExternalProject_Add_Step(${proj} CopyPyconfigHeader DEPENDEES install ) -if(Slicer_USE_PYTHONQT_WITH_TCL) +if(${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL) ExternalProject_Add_Step(${proj} Copy_tkinterPyd COMMAND ${CMAKE_COMMAND} -E copy ${PythonPCBuildDir}/_tkinter.pyd ${CMAKE_BINARY_DIR}/python-build/Lib/_tkinter.pyd DEPENDEES install diff --git a/SuperBuild/External_qCDashAPI.cmake b/SuperBuild/External_qCDashAPI.cmake index 50a65783804ef71cd5f6ab1536f2930ba1b5223e..199e80783c0046de9371415ad42a2a498bfd077b 100644 --- a/SuperBuild/External_qCDashAPI.cmake +++ b/SuperBuild/External_qCDashAPI.cmake @@ -1,24 +1,42 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName qCDashAPI) #The find_package known name +set(proj qCDashAPI) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED qCDashAPI_DIR AND NOT EXISTS ${qCDashAPI_DIR}) - message(FATAL_ERROR "qCDashAPI_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory") endif() # Set dependency list -set(qCDashAPI_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(qCDashAPI) -set(proj qCDashAPI) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED qCDashAPI_DIR) +if(NOT DEFINED ${extProjName}_DIR) #message(STATUS "${__indent}Adding project ${proj}") # Set CMake OSX variable to pass down the external project @@ -30,32 +48,52 @@ if(NOT DEFINED qCDashAPI_DIR) -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) endif() + ### --- Project specific additions here if(NOT DEFINED git_protocol) - set(git_protocol "git") + set(git_protocol "git") endif() + set(${proj}_CMAKE_OPTIONS + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DBUILD_TESTING:BOOL=OFF + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY "${git_protocol}://github.com/jcfr/qCDashAPI.git") + set(${proj}_GIT_TAG "9cd19663c1884b28ba4ad4153b290bf9da5500ab") ExternalProject_Add(${proj} - GIT_REPOSITORY "${git_protocol}://github.com/jcfr/qCDashAPI.git" - GIT_TAG "9cd19663c1884b28ba4ad4153b290bf9da5500ab" - "${slicer_external_update}" - SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" CMAKE_GENERATOR ${gen} CMAKE_ARGS - ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} + #-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} #-DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} # Unused - -DBUILD_TESTING:BOOL=OFF - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + ${${proj}_CMAKE_OPTIONS} INSTALL_COMMAND "" DEPENDS - ${qCDashAPI_DEPENDENCIES} - ) - set(qCDashAPI_DIR ${CMAKE_BINARY_DIR}/${proj}-build) + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}-build) else() - # The project is provided using qCDashAPI_DIR, nevertheless since other project may depend on qCDashAPI, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${qCDashAPI_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_qMidasAPI.cmake b/SuperBuild/External_qMidasAPI.cmake index d0cb179f707dfbe89552654070d7d6dcd09676ae..1b170d72cc3b84cc6b7cc725b1c98bbfd637affc 100644 --- a/SuperBuild/External_qMidasAPI.cmake +++ b/SuperBuild/External_qMidasAPI.cmake @@ -1,24 +1,42 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName qMidasAPI) #The find_package known name +set(proj qMidasAPI) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + # Sanity checks -if(DEFINED qMidasAPI_DIR AND NOT EXISTS ${qMidasAPI_DIR}) - message(FATAL_ERROR "qMidasAPI_DIR variable is defined but corresponds to non-existing directory") +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") endif() # Set dependency list -set(qMidasAPI_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(qMidasAPI) -set(proj qMidasAPI) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED qMidasAPI_DIR) +if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "${USE_SYSTEM_${extProjName}}" AND NOT "${USE_SYSTEM_${extProjName}}" ) ) ) #message(STATUS "${__indent}Adding project ${proj}") # Set CMake OSX variable to pass down the external project @@ -30,16 +48,25 @@ if(NOT DEFINED qMidasAPI_DIR) -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) endif() + ### --- Project specific additions here if(NOT DEFINED git_protocol) - set(git_protocol "git") + set(git_protocol "git") endif() + set(${proj}_CMAKE_OPTIONS + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DBUILD_TESTING:BOOL=OFF + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY "${git_protocol}://github.com/Slicer/qMidasAPI.git") + set(${proj}_GIT_TAG "2fae646e963a43d0cae7af52c18e78ce43a75f0c") ExternalProject_Add(${proj} - GIT_REPOSITORY "${git_protocol}://github.com/Slicer/qMidasAPI.git" - GIT_TAG "2fae646e963a43d0cae7af52c18e78ce43a75f0c" - "${slicer_external_update}" - SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" CMAKE_GENERATOR ${gen} CMAKE_ARGS -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} @@ -47,17 +74,26 @@ if(NOT DEFINED qMidasAPI_DIR) -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} #-DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} # Unused ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DBUILD_TESTING:BOOL=OFF - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + ${${proj}_CMAKE_OPTIONS} INSTALL_COMMAND "" DEPENDS - ${qMidasAPI_DEPENDENCIES} + ${${proj}_DEPENDENCIES} ) - set(qMidasAPI_DIR ${CMAKE_BINARY_DIR}/${proj}-build) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}-build) else() - # The project is provided using qMidasAPI_DIR, nevertheless since other project may depend on qMidasAPI, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${qMidasAPI_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_tcl.cmake b/SuperBuild/External_tcl.cmake index c78861801b23e15b21826f51c935f8057c45aa29..8a8a4595306bdab852ac2a2063afcb5b0640d608 100644 --- a/SuperBuild/External_tcl.cmake +++ b/SuperBuild/External_tcl.cmake @@ -1,20 +1,53 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName tcl) #The find_package known name +set(proj tcl) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + # Set dependency list -set(tcl_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(tcl) -set(proj tcl) +SlicerMacroCheckExternalProjectDependency(${proj}) -#message(STATUS "${__indent}Adding project ${proj}") + #message(STATUS "${__indent}Adding project ${proj}") + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here set(tcl_SVN_REPOSITORY) set(tcl_SOURCE_DIR "") set(tcl_BINARY_DIR "") @@ -78,14 +111,14 @@ endif() ExternalProject_Add(${proj} SVN_REPOSITORY ${tcl_SVN_REPOSITORY} SVN_REVISION ${tcl_SVN_REVISION} - "${slicer_external_disable_update}" + "${cmakeversion_external_disable_update}" SOURCE_DIR ${tcl_SOURCE_DIR} BUILD_IN_SOURCE ${tcl_BUILD_IN_SOURCE} CONFIGURE_COMMAND ${tcl_CONFIGURE_COMMAND} BUILD_COMMAND ${tcl_BUILD_COMMAND} INSTALL_COMMAND ${tcl_INSTALL_COMMAND} DEPENDS - ${tcl_DEPENDENCIES} + ${${proj}_DEPENDENCIES} ) #----------------------------------------------------------------------------- @@ -96,5 +129,9 @@ if(APPLE) COMMAND chmod u+xw ${tcl_build}/lib/libtcl${TCL_TK_VERSION_DOT}.dylib DEPENDEES install ) +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + endif() +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_teem.cmake b/SuperBuild/External_teem.cmake deleted file mode 100644 index fd56c09d43c8e845dabbc907b023422ac6de3bbb..0000000000000000000000000000000000000000 --- a/SuperBuild/External_teem.cmake +++ /dev/null @@ -1,87 +0,0 @@ - -# Make sure this file is included only once -get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) -if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) - return() -endif() -set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) - -# Set dependency list -set(teem_DEPENDENCIES VTK) - -# Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(teem) -set(proj teem) - -# Set CMake OSX variable to pass down the external project -set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) -if(APPLE) - list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS - -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) -endif() - -set(CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG) -if(CTEST_USE_LAUNCHERS) - set(CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG - "-DCMAKE_PROJECT_Teem_INCLUDE:FILEPATH=${CMAKE_ROOT}/Modules/CTestUseLaunchers.cmake") -endif() - -#message(STATUS "${__indent}Adding project ${proj}") - -if(WIN32) - set(teem_ZLIB_LIBRARY ${VTK_DIR}/bin/${CMAKE_CFG_INTDIR}/vtkzlib.lib) - set(teem_PNG_LIBRARY ${VTK_DIR}/bin/${CMAKE_CFG_INTDIR}/vtkpng.lib) -elseif(APPLE) - set(teem_ZLIB_LIBRARY ${VTK_DIR}/bin/libvtkzlib.dylib) - set(teem_PNG_LIBRARY ${VTK_DIR}/bin/libvtkpng.dylib) -else() - set(teem_ZLIB_LIBRARY ${VTK_DIR}/bin/libvtkzlib.so) - set(teem_PNG_LIBRARY ${VTK_DIR}/bin/libvtkpng.so) -endif() - -set(teem_URL http://svn.slicer.org/Slicer3-lib-mirrors/trunk/teem-1.10.0-src.tar.gz) -set(teem_MD5 efe219575adc89f6470994154d86c05b) - -ExternalProject_Add(${proj} - URL ${teem_URL} - URL_MD5 ${teem_MD5} - DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR} - SOURCE_DIR teem - BINARY_DIR teem-build - "${slicer_external_update}" - CMAKE_GENERATOR ${gen} - CMAKE_ARGS - -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} - # Not needed -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} - -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} - -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} - ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DBUILD_TESTING:BOOL=OFF - -DBUILD_SHARED_LIBS:BOOL=ON - ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} - ${CMAKE_PROJECT_INCLUDE_EXTERNAL_PROJECT_ARG} - -DTeem_USE_LIB_INSTALL_SUBDIR:BOOL=ON - -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF - -DTeem_PTHREAD:BOOL=OFF - -DTeem_BZIP2:BOOL=OFF - -DTeem_ZLIB:BOOL=ON - -DTeem_PNG:BOOL=ON - -DTeem_VTK_MANGLE:BOOL=ON - -DTeem_VTK_TOOLKITS_IPATH:FILEPATH=${VTK_DIR} - -DZLIB_INCLUDE_DIR:PATH=${VTK_SOURCE_DIR}/Utilities - -DTeem_VTK_ZLIB_MANGLE_IPATH:PATH=${VTK_SOURCE_DIR}/Utilities/vtkzlib - -DTeem_ZLIB_DLLCONF_IPATH:PATH=${VTK_DIR}/Utilities - -DZLIB_LIBRARY:FILEPATH=${teem_ZLIB_LIBRARY} - -DPNG_PNG_INCLUDE_DIR:PATH=${VTK_SOURCE_DIR}/Utilities/vtkpng - -DTeem_PNG_DLLCONF_IPATH:PATH=${VTK_DIR}/Utilities - -DPNG_LIBRARY:FILEPATH=${teem_PNG_LIBRARY} - INSTALL_COMMAND "" - DEPENDS - ${teem_DEPENDENCIES} - ) - -set(Teem_DIR ${CMAKE_BINARY_DIR}/teem-build) - diff --git a/SuperBuild/External_tk.cmake b/SuperBuild/External_tk.cmake index 679f4f8618ae7d1f10515eb1aba06594ba4ea1f1..8ee0f3ed91b21892effe2aa044f3fe8bc460e592 100644 --- a/SuperBuild/External_tk.cmake +++ b/SuperBuild/External_tk.cmake @@ -1,5 +1,6 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() @@ -7,16 +8,47 @@ endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) if(NOT WIN32) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName tk) #The find_package known name +set(proj tk) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() - # Set dependency list - set(tk_DEPENDENCIES tcl) +# Set dependency list +set(${proj}_DEPENDENCIES "tcl") - # Include dependent projects if any - SlicerMacroCheckExternalProjectDependency(tk) - set(proj tk) +# Include dependent projects if any +SlicerMacroCheckExternalProjectDependency(${proj}) #message(STATUS "${__indent}Adding project ${proj}") + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here set(tk_SVN_REPOSITORY "http://svn.slicer.org/Slicer3-lib-mirrors/trunk/tcl/tk") set(tk_SVN_REVISION -r "114") set(tk_SOURCE_DIR "") @@ -54,17 +86,18 @@ if(NOT WIN32) set(tk_INSTALL_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/tk_install_step.cmake) + ### --- End Project specific additions ExternalProject_Add(${proj} SVN_REPOSITORY ${tk_SVN_REPOSITORY} SVN_REVISION ${tk_SVN_REVISION} - "${slicer_external_disable_update}" + "${cmakeversion_external_disable_update}" SOURCE_DIR ${tk_SOURCE_DIR} BUILD_IN_SOURCE ${tk_BUILD_IN_SOURCE} CONFIGURE_COMMAND ${tk_CONFIGURE_COMMAND} BUILD_COMMAND ${tk_BUILD_COMMAND} INSTALL_COMMAND ${tk_INSTALL_COMMAND} DEPENDS - ${tk_DEPENDENCIES} + ${${proj}_DEPENDENCIES} ) ExternalProject_Add_Step(${proj} Install_default.h @@ -91,5 +124,9 @@ if(NOT WIN32) DEPENDEES install ) endif() -endif() +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) +endif() diff --git a/SuperBuild/External_weave.cmake b/SuperBuild/External_weave.cmake index e3f49dd2ec259841329d1fd8aa7febc6db99c4ce..4432c621af54b0194b234c74865391202241d0af 100644 --- a/SuperBuild/External_weave.cmake +++ b/SuperBuild/External_weave.cmake @@ -1,17 +1,40 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName weave) #The find_package known name +set(proj weave) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + # Set dependency list -set(weave_DEPENDENCIES python NUMPY) +set(${proj}_DEPENDENCIES python NUMPY) # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(weave) -set(proj weave) +SlicerMacroCheckExternalProjectDependency(${proj}) #message(STATUS "${__indent}Adding project ${proj}") @@ -33,10 +56,10 @@ configure_file( # create an external project to download weave, # and configure and build it ExternalProject_Add(weave - # URL ${Slicer_SOURCE_DIR}/Modules/Python/FilteredTractography/weave + # URL ${${PROJECT_NAME}_SOURCE_DIR}/Modules/Python/FilteredTractography/weave SVN_REPOSITORY http://svn.slicer.org/Slicer3-lib-mirrors/trunk/weave SVN_REVISION -r "154" - "${slicer_external_disable_update}" + "${cmakeversion_external_disable_update}" BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/weave SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/weave BUILD_COMMAND ${CMAKE_COMMAND} @@ -44,5 +67,8 @@ ExternalProject_Add(weave CONFIGURE_COMMAND "" INSTALL_COMMAND "" DEPENDS - ${weave_DEPENDENCIES} + ${${proj}_DEPENDENCIES} ) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/External_zlib.cmake b/SuperBuild/External_zlib.cmake index 1753b912c6dc8e7ac23565c11c1cbea5ee046bb1..79e7bb56102f891c90aeb31046788d49e19472ce 100644 --- a/SuperBuild/External_zlib.cmake +++ b/SuperBuild/External_zlib.cmake @@ -1,27 +1,44 @@ -# Make sure this file is included only once +# Make sure this file is included only once by creating globally unique varibles +# based on the name of this included file. get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) return() endif() set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1) +## External_${extProjName}.cmake files can be recurisvely included, +## and cmake variables are global, so when including sub projects it +## is important make the extProjName and proj variables +## appear to stay constant in one of these files. +## Store global variables before overwriting (then restore at end of this file.) +ProjectDependancyPush(CACHED_extProjName ${extProjName}) +ProjectDependancyPush(CACHED_proj ${proj}) + +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName zlib) #The find_package known name +set(proj zlib) #This local name + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + # Set dependency list -set(zlib_DEPENDENCIES "") +set(${proj}_DEPENDENCIES "") # Include dependent projects if any -SlicerMacroCheckExternalProjectDependency(zlib) -set(proj zlib) +SlicerMacroCheckExternalProjectDependency(${proj}) -if(NOT DEFINED zlib_DIR) +if(NOT DEFINED ${extProjName}_DIR) #message(STATUS "${__indent}Adding project ${proj}") - set(ADDITIONAL_CMAKE_ARGS) - set(zlib_c_flags ${ep_common_c_flags}) - if(WIN32) - set(zlib_c_flags "${ep_common_c_flags} /DZLIB_WINAPI") - endif() - # Set CMake OSX variable to pass down the external project set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) if(APPLE) @@ -31,33 +48,59 @@ if(NOT DEFINED zlib_DIR) -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}) endif() + ### --- Project specific additions here + set(ADDITIONAL_CMAKE_ARGS) + set(zlib_c_flags ${ep_common_c_flags}) + if(WIN32) + set(zlib_c_flags "${ep_common_c_flags} /DZLIB_WINAPI") + endif() + if(NOT DEFINED git_protocol) - set(git_protocol "git") + set(git_protocol "git") endif() + set(${proj}_CMAKE_OPTIONS + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DZLIB_MANGLE_PREFIX:STRING=la_zlib_ + ${ADDITIONAL_CMAKE_ARGS} + -DCMAKE_INSTALL_PREFIX:PATH= + ) + ### --- End Project specific additions + set(${proj}_REPOSITORY "${git_protocol}://github.com/commontk/zlib.git") + set(${proj}_GIT_TAG "66a753054b356da85e1838a081aa94287226823e") ExternalProject_Add(${proj} - GIT_REPOSITORY "${git_protocol}://github.com/commontk/zlib.git" - GIT_TAG "66a753054b356da85e1838a081aa94287226823e" - "${slicer_external_update}" - SOURCE_DIR zlib - BINARY_DIR zlib-build + GIT_REPOSITORY ${${proj}_REPOSITORY} + GIT_TAG ${${proj}_GIT_TAG} + SOURCE_DIR ${proj} + BINARY_DIR ${proj}-build + "${cmakeversion_external_update}" INSTALL_DIR zlib-install CMAKE_GENERATOR ${gen} CMAKE_ARGS - ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + #-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} # -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} # Not used + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} -DCMAKE_C_FLAGS:STRING=${zlib_c_flags} - -DZLIB_MANGLE_PREFIX:STRING=la_zlib_ - ${ADDITIONAL_CMAKE_ARGS} - -DCMAKE_INSTALL_PREFIX:PATH= + ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} + ${${proj}_CMAKE_OPTIONS} DEPENDS - ${zlib_DEPENDENCIES} - ) - set(zlib_DIR ${CMAKE_BINARY_DIR}/zlib-install) + ${${proj}_DEPENDENCIES} + ) + set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/${proj}-install) else() - # The project is provided using zlib_DIR, nevertheless since other project may depend on zlib, - # let's add an 'empty' one - SlicerMacroEmptyExternalProject(${proj} "${zlib_DEPENDENCIES}") + if(${USE_SYSTEM_${extProjName}}) + find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED) + if(NOT ${extProjName}_DIR) + message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR") + endif() + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}") endif() +list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH) + +ProjectDependancyPop(CACHED_extProjName extProjName) +ProjectDependancyPop(CACHED_proj proj) diff --git a/SuperBuild/python_configure_step.cmake.in b/SuperBuild/python_configure_step.cmake.in index e9dec1b77af783d04e91a3543cf57b9c7da65dca..182e7f99f3f93465f1b51d93780b3701d695a856 100644 --- a/SuperBuild/python_configure_step.cmake.in +++ b/SuperBuild/python_configure_step.cmake.in @@ -9,9 +9,9 @@ if(UNIX) set(CPPFLAGS) set(LD_LIBRARY_PATH "@CMAKE_CURRENT_BINARY_DIR@/python-build/lib") - set(Slicer_USE_PYTHONQT_WITH_TCL "@Slicer_USE_PYTHONQT_WITH_TCL@") + set(${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL "@${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL@") set(with_tcl_param) - if(Slicer_USE_PYTHONQT_WITH_TCL) + if(${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL) set(LD_LIBRARY_PATH "@CMAKE_CURRENT_BINARY_DIR@/tcl-build/lib:${LD_LIBRARY_PATH}") set(LDFLAGS "-L@CMAKE_CURRENT_BINARY_DIR@/tcl-build/lib") set(CPPFLAGS "-I@CMAKE_CURRENT_BINARY_DIR@/tcl-build/include") diff --git a/SuperBuild/python_install_step.cmake.in b/SuperBuild/python_install_step.cmake.in index 9dc6c6a2a4ba650a00d021681c55c49a91deb20a..890b0ea2889114671d6c287922a013a6c4c74f2a 100644 --- a/SuperBuild/python_install_step.cmake.in +++ b/SuperBuild/python_install_step.cmake.in @@ -9,8 +9,8 @@ if(UNIX) set(CPPFLAGS) set(LD_LIBRARY_PATH "@CMAKE_CURRENT_BINARY_DIR@/python-build/lib") - set(Slicer_USE_PYTHONQT_WITH_TCL "@Slicer_USE_PYTHONQT_WITH_TCL@") - if(Slicer_USE_PYTHONQT_WITH_TCL) + set(${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL "@${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL@") + if(${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL) set(LD_LIBRARY_PATH "@CMAKE_CURRENT_BINARY_DIR@/tcl-build/lib:${LD_LIBRARY_PATH}") set(LDFLAGS "-L@CMAKE_CURRENT_BINARY_DIR@/tcl-build/lib") set(CPPFLAGS "-I@CMAKE_CURRENT_BINARY_DIR@/tcl-build/include") diff --git a/SuperBuild/python_make_step.cmake.in b/SuperBuild/python_make_step.cmake.in index 6ac98140bd5bcc77bee8261a928096c258ef9699..37f3dd5c8efdc5047b0c723d24f28f83907eac65 100644 --- a/SuperBuild/python_make_step.cmake.in +++ b/SuperBuild/python_make_step.cmake.in @@ -10,9 +10,9 @@ if(UNIX) set(CPPFLAGS) set(LD_LIBRARY_PATH "@CMAKE_CURRENT_BINARY_DIR@/python-build/lib") - set(Slicer_USE_PYTHONQT_WITH_TCL "@Slicer_USE_PYTHONQT_WITH_TCL@") + set(${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL "@${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL@") - if(Slicer_USE_PYTHONQT_WITH_TCL) + if(${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL) set(LD_LIBRARY_PATH "@CMAKE_CURRENT_BINARY_DIR@/tcl-build/lib:${LD_LIBRARY_PATH}") set(LDFLAGS "-L@CMAKE_CURRENT_BINARY_DIR@/tcl-build/lib") set(CPPFLAGS "-I@CMAKE_CURRENT_BINARY_DIR@/tcl-build/include") diff --git a/SuperBuild/python_patch_step_win.cmake.in b/SuperBuild/python_patch_step_win.cmake.in index 185ddd627f0eb9e31f82973c8824106252e292d9..d46bad1974fe63d0a6e81b6f1c543fd26704b9c4 100644 --- a/SuperBuild/python_patch_step_win.cmake.in +++ b/SuperBuild/python_patch_step_win.cmake.in @@ -24,7 +24,7 @@ configure_file( # Prevent warning about if(ON). cmake_policy(SET CMP0012 NEW) -if(@Slicer_USE_PYTHONQT_WITH_TCL@) +if(@${PROJECT_NAME}_USE_PYTHONQT_WITH_TCL@) # 32-bit or 64-bit if(@CMAKE_SIZEOF_VOID_P@ EQUAL 8) execute_process(COMMAND ${CMAKE_COMMAND} -Din:FILEPATH=@in@ -Dout:FILEPATH=@out@ -Dfind=\\tcltk64 -Dreplace=\\tcl-build -P "@script@")