Skip to content

Commit

Permalink
COMP: Fix build ensuring inner-build doesn't override the outer build
Browse files Browse the repository at this point in the history
* Ensure inner-build doesn't override the outer build by setting
  the EXTENSION_BUILD_SUBDIRECTORY variable specific to the SuperBuild
  extension layout.

* Fix inner build ensuring the Slicer_DIR variable is propagated.

* Ensure the Git executable is consistently set and remove obsolete
  workaround. Note also that Subversion is not used anymore.

* Ensure CMake options specific to CXX standard are propagated.

* Remove obsolete <proj>_USE_GIT_PROTOCOL variable. It is now defined and
  set in the ExternalProjectDependency CMake module.
  Note also that the default is now set to "https" as GitHub removed
  unauthenticated access through the git protocol.
  See https://github.blog/2021-09-01-improving-git-protocol-security-github/

* Remove obsolete MIDAS_PACKAGE_* variables. Upload of extension is done
  using a different mechanism. See Slicer/Slicer@359f95c9b (COMP: Simplify
  extension package upload logic removing midas support)

* Remove explicit and incorrect setting of CMAKE_BUILD_TYPE option. The option
  is set only for single-config CMake generator (e.g Unix Makefiles) after
  calling "include(${Slicer_USE_FILE})" which indirectly includes the
  "SlicerInitializeBuildType" CMake module.
  • Loading branch information
jcfr committed Apr 20, 2023
1 parent cc78514 commit c760643
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ set(EXTENSION_DESCRIPTION "A Slicer module for automated and interactive quality
set(EXTENSION_ICONURL "https://raw.githubusercontent.com/pnlbwh/SlicerDiffusionQC/master/Misc/DiffusionQC-icon-128x128.png")
set(EXTENSION_SCREENSHOTURLS "https://github.com/pnlbwh/SlicerDiffusionQC/raw/master/Misc/DiffusionQC-screenshot.jpg")
set(EXTENSION_DEPENDS "SlicerDMRI") # Specified as a space separated string, a list or 'NA' if any
set(EXTENSION_BUILD_SUBDIRECTORY inner-build)

#-----------------------------------------------------------------------------
# Extension dependencies
find_package(Slicer REQUIRED)
include(${Slicer_USE_FILE})
mark_as_superbuild(Slicer_DIR)

find_package(Git REQUIRED)
mark_as_superbuild(GIT_EXECUTABLE)

#-----------------------------------------------------------------------------
# SuperBuild setup
Expand Down
28 changes: 6 additions & 22 deletions SuperBuild.cmake
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
include(SlicerCheckCMakeHTTPS)
slicer_check_cmake_https()

#-----------------------------------------------------------------------------
# Git protocol option
#-----------------------------------------------------------------------------
option(${CMAKE_PROJECT_NAME}_USE_GIT_PROTOCOL "If behind a firewall turn this off to use http instead." ON)

set(git_protocol "git")
if(NOT ${CMAKE_PROJECT_NAME}_USE_GIT_PROTOCOL)
set(git_protocol "http")
endif()

#-----------------------------------------------------------------------------
# Enable and setup External project global properties
#-----------------------------------------------------------------------------
Expand All @@ -36,14 +26,6 @@ ExternalProject_Include_Dependencies(${proj}
SUPERBUILD_VAR ${EXTENSION_NAME}_SUPERBUILD
)

# XXX Workaround https://gitlab.kitware.com/cmake/cmake/issues/15448
# and explicitly pass GIT_EXECUTABLE and Subversion_SVN_EXECUTABLE
foreach(varname IN ITEMS GIT_EXECUTABLE Subversion_SVN_EXECUTABLE)
if(EXISTS "${${varname}}")
list(APPEND DCMQI_EP_CMAKE_CACHE_ARGS -D${varname}:FILEPATH=${${varname}})
endif()
endforeach()

ExternalProject_Add(${proj}
${${proj}_EP_ARGS}
DOWNLOAD_COMMAND ""
Expand All @@ -52,19 +34,21 @@ ExternalProject_Add(${proj}
BINARY_DIR ${EXTENSION_BUILD_SUBDIRECTORY}
BUILD_ALWAYS 1
CMAKE_CACHE_ARGS
# Compiler settings
-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_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_STANDARD_REQUIRED:BOOL=${CMAKE_CXX_STANDARD_REQUIRED}
-DCMAKE_CXX_EXTENSIONS:BOOL=${CMAKE_CXX_EXTENSIONS}
# Output directories
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
-DMIDAS_PACKAGE_EMAIL:STRING=${MIDAS_PACKAGE_EMAIL}
-DMIDAS_PACKAGE_API_KEY:STRING=${MIDAS_PACKAGE_API_KEY}
# Superbuild
-D${EXTENSION_NAME}_SUPERBUILD:BOOL=OFF
-DEXTENSION_SUPERBUILD_BINARY_DIR:PATH=${${EXTENSION_NAME}_BINARY_DIR}
${DCMQI_EP_CMAKE_CACHE_ARGS}
DEPENDS
${${proj}_DEPENDS}
)
Expand Down

0 comments on commit c760643

Please sign in to comment.