Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update buildsystem to support customapp bundling #149

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
465a87f
STYLE: Strip trailing spaces
jcfr Jan 13, 2023
3a52fbb
STYLE: Convert tabs to spaces
jcfr Jan 13, 2023
22e2907
COMP: Fix configuration against Slicer by updating default C++ version
jcfr Jan 13, 2023
1990f30
COMP: Specify VTK component using updated convention
jcfr Jan 13, 2023
8d55b51
COMP: Remove obsolete integration of VTK_USE_FILE
jcfr Jan 13, 2023
c5f4f7d
COMP: Fix configuration updating ITKSetStandardCompilerFlags
jcfr Jan 13, 2023
d1ebd42
COMP: Update CMake/PreventIn* modules
jcfr Jan 13, 2023
6db1f5c
COMP: Remove copy of ExternalData CMake module
jcfr Jan 13, 2023
af99662
COMP: Remove unused NAMICExternalProjectsExternalData CMake module
jcfr Jan 13, 2023
ca9c8fa
COMP: Update Boost external project to support VS 2019
jcfr Jan 25, 2023
19bc16b
STYLE: Update Boost external project describing Visual Studio version
jcfr Jan 25, 2023
f98bc9b
COMP: Update Boost external project adding support for VS 2022
jcfr Jan 25, 2023
65d7480
STYLE: Set Eigen repository and version in corresponding external pro…
jcfr Jan 25, 2023
2b1840c
COMP: Remove unused and obsolete UKFTractography_USE_GIT_PROTOCOL option
jcfr Jan 25, 2023
aea46e1
COMP: Ensure GIT_EXECUTABLE is passed to inner build
jcfr Jan 25, 2023
df25884
COMP: Include "Common.cmake" in top-level CMakeLists.txt
jcfr Jan 25, 2023
8b9795f
COMP: Execute PreventIn(BuildInstalls|SourceBuilds) check as early as…
jcfr Jan 25, 2023
1cb59ea
COMP: Simplify OSX Deployment target setting
jcfr Jan 25, 2023
32ec799
COMP: Require at least macOS 10.13
jcfr Jan 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMake/CTestCustom.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION
"SlicerExecutionModel"
"SimpleITK"

".*has no symbols",
".*has no symbols",
"CMake Warning:",
"note: expanded from macro",
": note:",
Expand Down
789 changes: 0 additions & 789 deletions CMake/ExternalData.cmake

This file was deleted.

4 changes: 0 additions & 4 deletions CMake/ExternalData_config.cmake.in

This file was deleted.

2 changes: 1 addition & 1 deletion CMake/ExternalProjectGenerateProjectDescription.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ if(NOT license_found)
message(AUTHOR_WARNING \"${name}: Could not find a license file\")
endif()
")

ExternalProject_Add_Step(${projectname} generate_project_description
COMMAND ${CMAKE_COMMAND} -P ${script}
COMMENT "Generate ${generated_version_file} and ${generated_license_file}"
Expand Down
198 changes: 90 additions & 108 deletions CMake/ITKSetStandardCompilerFlags.cmake

Large diffs are not rendered by default.

42 changes: 0 additions & 42 deletions CMake/ITK_CheckCCompilerFlag.cmake

This file was deleted.

42 changes: 0 additions & 42 deletions CMake/ITK_CheckCXXCompilerFlag.cmake

This file was deleted.

47 changes: 0 additions & 47 deletions CMake/NAMICExternalProjectsExternalData.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion CMake/PreventInBuildInstalls.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Adapated from ITK/CMake/PreventInBuildInstalls.cmake
string(TOLOWER "${CMAKE_INSTALL_PREFIX}" _PREFIX)
string(TOLOWER "${${CMAKE_PROJECT_NAME}_BINARY_DIR}" _BUILD)
string(TOLOWER "${CMAKE_BINARY_DIR}" _BUILD)
if("${_PREFIX}" STREQUAL "${_BUILD}")
message(FATAL_ERROR
"The current CMAKE_INSTALL_PREFIX points at the build tree:\n"
Expand Down
46 changes: 18 additions & 28 deletions CMake/PreventInSourceBuilds.cmake
Original file line number Diff line number Diff line change
@@ -1,56 +1,46 @@
# Adapated from ITK/CMake/PreventInSourceBuilds.cmake
#
# This function will prevent in-source builds
function(AssureOutOfSourceBuilds PROJECT_NAME)
function(AssureOutOfSourceBuilds ORG_NAME PROJECT_NAME)
# make sure the user doesn't play dirty with symlinks
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)

# disallow in-source builds
if("${srcdir}" STREQUAL "${bindir}")
message("###########################################################################")
message("######################################################")
message("# ${PROJECT_NAME} should not be configured & built in the ${PROJECT_NAME} source directory")
message("# You must run cmake in a build directory.")
message("# For example:")
message("#")
message("# mkdir ${PROJECT_NAME}-Sandbox ; cd ${PROJECT_NAME}-sandbox")
message("#")
message("# Check out source code in ${PROJECT_NAME}-sandbox")
message("#")
message("# mkdir ${PROJECT_NAME}-build")
message("#")
message("# mkdir ${PROJECT_NAME}-sandbox ; cd ${PROJECT_NAME}-sandbox")
message("# git clone git://github.com/${ORG_NAME}/${PROJECT_NAME}.git # or download & unpack the source tarball")
message("# mkdir ${PROJECT_NAME}-SuperBuild")
message("# this will create the following directory structure")
message("#")
message("# ${PROJECT_NAME}-Sandbox")
message("# ${PROJECT_NAME}-sandbox")
message("# +--${PROJECT_NAME}")
message("# +--${PROJECT_NAME}-build")
message("# +--${PROJECT_NAME}-SuperBuild")
message("#")
message("# Then you can proceed to configure and build")
message("# by using the following commands")
message("#")
message("# cd ${PROJECT_NAME}-build")
message("# cmake ../${PROJECT_NAME} # or ccmake, or cmake-gui")
message("# make")
message("# cd ${PROJECT_NAME}-SuperBuild")
message("# cmake ../${PROJECT_NAME} # or ccmake, or cmake-gui ")
message("# make")
message("#")
message("# NOTE: Given that you already tried to make an in-source build")
message("# CMake have already created several files & directories")
message("# in your source tree.")
message("# in your source tree. run 'git status' to find them and")
message("# remove them by doing:")
message("#")
message("# The following command will show you all files not part of ${PROJECT_NAME}")
message("# cd ${PROJECT_NAME}-Sandbox/${PROJECT_NAME}")
message("# svn status | grep '[^?]' | awk '{print \$2}'")
message("# cd ${PROJECT_NAME}-sandbox/${PROJECT_NAME}")
message("# git clean -n -d")
message("# git clean -f -d")
message("# git checkout --")
message("#")
message("# WARNING: if you have added files to ${PROJECT_NAME} but not used svn add")
message("# to add them to SVN's version control, this command will display them")
message("# along with the files CMake created during configuration. You will need")
message("# to either save them outside the ${PROJECT_NAME} source tree, or run svn add")
message("# to let SVN know they are legitimate source files.")
message("# Once you've verified that all unknown files are the result of CMake")
message("# configuration, you can run this command to clean them up")
message("# svn status | grep '[^?]' | awk '{print \$2}' | xargs rm -fr")
message("###########################################################################")
message("######################################################")
message(FATAL_ERROR "Quitting configuration")
endif()
endfunction()

AssureOutOfSourceBuilds(${CMAKE_PROJECT_NAME})
AssureOutOfSourceBuilds("pnlbwh" "ukftractography")
83 changes: 8 additions & 75 deletions CMake/SlicerBlockSetCMakeOSXVariables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#

#
# Adapted from Paraview/Superbuild/CMakeLists.txt
# Adapted from Slicer/CMake/SlicerInitializeOSXVariables.cmake
#

# Note: Change architecture *before* any enable_language() or project()
Expand All @@ -32,88 +32,21 @@
#
if(APPLE)

# Waiting universal binaries are supported and tested, complain if
# multiple architectures are specified.
# Disable universal binaries
if(NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
list(LENGTH CMAKE_OSX_ARCHITECTURES arch_count)
if(arch_count GREATER 1)
message(FATAL_ERROR "error: Only one value (i386 or x86_64) should be associated with CMAKE_OSX_ARCHITECTURES.")
endif()
endif()

# See CMake/Modules/Platform/Darwin.cmake)
# 8.x == Mac OSX 10.4 (Tiger)
# 9.x == Mac OSX 10.5 (Leopard)
# 10.x == Mac OSX 10.6 (Snow Leopard)
# 11.x == Mac OSX 10.7 (Lion)
# 12.x == Mac OSX 10.8 (Mountain Lion)
# 13.x == Mac OSX 10.9 (Mavericks)
# 14.x == Mac OSX 10.10 (Yosemite)
set(OSX_SDK_104_NAME "Tiger")
set(OSX_SDK_105_NAME "Leopard")
set(OSX_SDK_106_NAME "Snow Leopard")
set(OSX_SDK_107_NAME "Lion")
set(OSX_SDK_108_NAME "Mountain Lion")
set(OSX_SDK_109_NAME "Mavericks")
set(OSX_SDK_1010_NAME "Yosemite")

set(OSX_SDK_ROOTS
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
/Developer/SDKs
)

# Explicitly set the OSX_SYSROOT to the latest one, as its required
# when the SX_DEPLOYMENT_TARGET is explicitly set
foreach(SDK_ROOT ${OSX_SDK_ROOTS})
if( "x${CMAKE_OSX_SYSROOT}x" STREQUAL "xx")
file(GLOB SDK_SYSROOTS "${SDK_ROOT}/MacOSX*.sdk")

if(NOT "x${SDK_SYSROOTS}x" STREQUAL "xx")
set(SDK_SYSROOT_NEWEST "")
set(SDK_VERSION "0")
# find the latest SDK
foreach(SDK_ROOT_I ${SDK_SYSROOTS})
# extract version from SDK
string(REGEX MATCH "MacOSX([0-9]+\\.[0-9]+)\\.sdk" _match "${SDK_ROOT_I}")
if("${CMAKE_MATCH_1}" VERSION_GREATER "${SDK_VERSION}")
set(SDK_SYSROOT_NEWEST "${SDK_ROOT_I}")
set(SDK_VERSION "${CMAKE_MATCH_1}")
endif()
endforeach()

if(NOT "x${SDK_SYSROOT_NEWEST}x" STREQUAL "xx")
string(REPLACE "." "" sdk_version_no_dot ${SDK_VERSION})
set(OSX_NAME ${OSX_SDK_${sdk_version_no_dot}_NAME})
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Force build for 64-bit ${OSX_NAME}." FORCE)
set(CMAKE_OSX_SYSROOT "${SDK_SYSROOT_NEWEST}" CACHE PATH "Force build for 64-bit ${OSX_NAME}." FORCE)
message(STATUS "Setting OSX_ARCHITECTURES to '${CMAKE_OSX_ARCHITECTURES}' as none was specified.")
message(STATUS "Setting OSX_SYSROOT to latest '${CMAKE_OSX_SYSROOT}' as none was specified.")
endif()
endif()
endif()
endforeach()

set(required_deployment_target "10.13")
if("x${CMAKE_OSX_DEPLOYMENT_TARGET}x" STREQUAL "xx")
string(REGEX MATCH "MacOSX([0-9]+\\.[0-9]+)\\.sdk" _match "${CMAKE_OSX_SYSROOT}")
set(SDK_VERSION "${CMAKE_MATCH_1}")
if( "${SDK_VERSION}" VERSION_GREATER "10.8" )
# add to cache to allow interactive editing after fatal error
set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE PATH "Deployment target needs to be explicitly set." FORCE)
message(FATAL_ERROR
"The OSX_SYSROOT is set to version ${SDK_VERSION} (>10.8) and OSX_DEPLOYMENT_TARGET is not explicitly set!\n"
"Since:\n"
" (1) the default runtime associated with >=10.9 deployment target is 'libc++'.[1]\n"
" (2) the default runtime associated with <=10.8 deployment target is 'libstdc++'.\n"
" (3) Qt support for 'macx-clang-libc++' is listed as 'unsupported' mkspecs.\n"
" (4) Qt binaries may be build against 'libstdc++' or 'libc++'.\n"
" (5) Mixing the two different runtime in binaries is unstable.\n"
" [1]http://stackoverflow.com/questions/19637164/c-linking-error-after-upgrading-to-mac-os-x-10-9-xcode-5-0-1/19637199#19637199\n"
"--------------------------------\n"
"Run '$otool -L $(which qmake) |grep lib.\\*c++' to check what library Qt is built against:\n"
" (1) if it is libstdc++ then add '-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.8' (or older) to the cmake command line.\n"
" (2) if it is libc++ then add '-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9' (or newer) to the cmake command line.\n"
)
endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET ${required_deployment_target})
endif()

if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS ${required_deployment_target})
message(FATAL_ERROR "CMAKE_OSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET} must be ${required_deployment_target} or greater.")
endif()

if(NOT "${CMAKE_OSX_SYSROOT}" STREQUAL "")
Expand Down
19 changes: 14 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,27 @@ if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW) #3.12.0 `find_package()`` uses ``<PackageName>_ROOT`` variables.
endif()

#-----------------------------------------------------------------------------
# Enable C++11
#-----------------------------------------------------------------------------
# C++ standard
set(_msg "Setting C++ standard")
message(STATUS "${_msg}")
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
message(STATUS "${_msg} - C++${CMAKE_CXX_STANDARD}")

#-----------------------------------------------------------------------------
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMake)

# Sanity checks
include(PreventInSourceBuilds)
include(PreventInBuildInstalls)

# macOS initialization
if(APPLE AND DARWIN_MAJOR_VERSION LESS "10.13")
message(FATAL_ERROR "Only macOS >= 10.13 is supported")
endif()
include(SlicerBlockSetCMakeOSXVariables)

set(PRIMARY_PROJECT_NAME UKFTractography)
Expand Down Expand Up @@ -81,12 +88,14 @@ mark_as_advanced(ADDITIONAL_CXX_FLAGS)
#-----------------------------------------------------------------------------
# Required by Slicer extension build system for reasons. See
# https://github.com/Slicer/Slicer/commit/b160ec13f276a86306513954ef8b08a5332afc2e
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR};${EXTENSION_NAME};RuntimeLibraries;/")
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR};${EXTENSION_NAME};RuntimeLibraries;/")

#-----------------------------------------------------------------------------
# Superbuild script
#-----------------------------------------------------------------------------

include(${CMAKE_CURRENT_SOURCE_DIR}/Common.cmake) #<-- All feature options for top superbuild and inner product build

if(${PRIMARY_PROJECT_NAME}_SUPERBUILD)
project(SuperBuild_${PRIMARY_PROJECT_NAME} LANGUAGES C CXX) # <- NOTE: Project name for pre-requisites is different form main project
include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
Expand Down
Loading