Skip to content

Commit

Permalink
Change CMake and fix code problems with new Qt and MITK versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbolt committed May 15, 2024
1 parent 2723d45 commit ec3724c
Show file tree
Hide file tree
Showing 108 changed files with 40,431 additions and 14,366 deletions.
34 changes: 26 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,21 @@
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.10.0)
cmake_minimum_required(VERSION 3.24.0)
#cmake_minimum_required(VERSION 3.10.0)
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
Project(SV_TOP)
#-----------------------------------------------------------------------------

message(STATUS "========== SimVascular/CMakeLists ==========")

set(CMAKE_CXX_STANDARD 17)

cmake_policy(SET CMP0135 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)

#-----------------------------------------------------------------------------
# CMake module path inside of true simvascular source
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Code/CMake"
Expand Down Expand Up @@ -81,7 +89,8 @@ option(SV_USE_MITK_SEGMENTATION "Enable building the MITK segmentation plugin" O
#-----------------------------------------------------------------------------
# Externals!

set(SV_EXTERNALS_VERSION_NUMBER "2022.10" CACHE STRING "SimVascular Externals Release Version")
set(SV_EXTERNALS_VERSION_NUMBER "2024.05" CACHE STRING "SimVascular Externals Release Version")
#set(SV_EXTERNALS_VERSION_NUMBER "2022.10" CACHE STRING "SimVascular Externals Release Version")
mark_as_advanced(SV_EXTERNALS_VERSION_NUMBER)

# Distribution
Expand All @@ -90,11 +99,16 @@ option(SV_ENABLE_DISTRIBUTION "Enable Installer Build for SimVascular" OFF)
# sv4gui
option(SV_USE_SV4_GUI "Enable SV MITK/Qt Based GUI" ON)

# Set using pre-built Qt6 install.
#
if(APPLE)
option(SV_EXTERNALS_USE_PREBUILT_QT "Use Externally Installed Qt5" OFF)
set(SV_EXTERNALS_PREBUILT_QT_PATH "" CACHE PATH "Qt5 Cmake Config File Path" FORCE)
option(SV_EXTERNALS_USE_PREBUILT_QT "Use Externally Installed Qt6" OFF)
set(SV_EXTERNALS_PREBUILT_QT_PATH "/usr/local/opt/qt/lib/cmake/Qt6" CACHE PATH "Qt6 Cmake Config File Path" FORCE)
#set(SV_EXTERNALS_PREBUILT_QT_PATH "" CACHE PATH "Qt6 Cmake Config File Path" FORCE)

elseif(LINUX)
option(SV_EXTERNALS_USE_PREBUILT_QT "Use Externally Installed Qt5" OFF)
option(SV_EXTERNALS_USE_PREBUILT_QT "Use Externally Installed Qt6" OFF)

if(SV_EXTERNALS_VERSION_NUMBER VERSION_EQUAL "2018.01")
set(SV_EXTERNALS_PREBUILT_QT_PATH "/opt/Qt5.4.2/5.4/gcc_64/lib/cmake/Qt5" CACHE PATH "Qt5 Cmake Config File Path" FORCE)
elseif(SV_EXTERNALS_VERSION_NUMBER VERSION_EQUAL "2018.05")
Expand All @@ -106,6 +120,7 @@ elseif(LINUX)
else()
set(SV_EXTERNALS_PREBUILT_QT_PATH "" FORCE)
endif()

elseif(WIN32)
option(SV_EXTERNALS_USE_PREBUILT_QT "Use Externally Installed Qt5" OFF)
if(SV_EXTERNALS_VERSION_NUMBER VERSION_EQUAL "2018.01")
Expand All @@ -121,6 +136,9 @@ elseif(WIN32)
endif()
endif()

message(STATUS "[SimVascular/CMakeLists] SV_EXTERNALS_USE_PREBUILT_QT: ${SV_EXTERNALS_USE_PREBUILT_QT}")
message(STATUS "[SimVascular/CMakeLists] SV_EXTERNALS_PREBUILT_QT_PATH: ${SV_EXTERNALS_PREBUILT_QT_PATH}")

mark_as_advanced(SV_EXTERNALS_USE_PREBUILT_QT)
mark_as_advanced(SV_EXTERNALS_PREBUILT_QT_PATH)

Expand Down Expand Up @@ -156,7 +174,7 @@ ExternalProject_Add(Externals
-DSV_EXTERNALS_VERSION_NUMBER:STRING=${SV_EXTERNALS_VERSION_NUMBER}
-DSV_EXTERNALS_USE_PREBUILT_QT:BOOL=${SV_EXTERNALS_USE_PREBUILT_QT}
-DSV_EXTERNALS_PREBUILT_QT_PATH:PATH=${SV_EXTERNALS_PREBUILT_QT_PATH}
-DQt5_DIR:PATH=${SV_EXTERNALS_PREBUILT_QT_PATH}
-DQt6_DIR:PATH=${SV_EXTERNALS_PREBUILT_QT_PATH}
-DSV_EXTERNALS_TOPLEVEL_BIN_DIR:PATH=${SV_EXTERNALS_TOPLEVEL_BIN_DIR}
${SV_EXTERNALS_ADDITIONAL_CMAKE_ARGS}
)
Expand Down Expand Up @@ -204,7 +222,7 @@ ExternalProject_Add(SimVascular
-DSV_USE_MPICH2:BOOL=OFF
-DSV_USE_OpenCASCADE:BOOL=ON
-DSV_USE_PYTHON:BOOL=ON
-DSV_USE_Qt5:BOOL=ON
-DSV_USE_Qt6:BOOL=ON
-DSV_USE_QT:BOOL=ON
-DSV_USE_SV4_GUI:BOOL=${SV_USE_SV4_GUI}
-DSV_USE_MITK_SEGMENTATION:BOOL=${SV_USE_MITK_SEGMENTATION}
Expand All @@ -217,7 +235,7 @@ ExternalProject_Add(SimVascular
-DSV_EXTERNALS_USE_PREBUILT_QT:BOOL=${SV_EXTERNALS_USE_PREBUILT_QT}
-DSV_EXTERNALS_PREBUILT_QT_PATH:PATH=${SV_EXTERNALS_PREBUILT_QT_PATH}
-DSV_EXTERNALS_VERSION_NUMBER:STRING=${SV_EXTERNALS_VERSION_NUMBER}
-DQt5_DIR:PATH=${SV_EXTERNALS_PREBUILT_QT_PATH}
-DQt6_DIR:PATH=${SV_EXTERNALS_PREBUILT_QT_PATH}
${SV_ADDITIONAL_CMAKE_ARGS}
)
#-----------------------------------------------------------------------------
5 changes: 5 additions & 0 deletions Code/CMake/CppMicroServices/usFunctionAddResources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
#!
function(usFunctionAddResources)

message(STATUS " ")
message(STATUS "================ usFunctionAddResources ============== ")

cmake_parse_arguments(US_RESOURCE "" "TARGET;MODULE_NAME;WORKING_DIRECTORY;COMPRESSION_LEVEL" "FILES;ZIP_ARCHIVES" ${ARGN})

if(NOT US_RESOURCE_TARGET)
Expand Down Expand Up @@ -75,6 +78,8 @@ function(usFunctionAddResources)
endif()

set(resource_compiler ${US_RCC_EXECUTABLE})
message(STATUS "[usFunctionAddResources] US_RCC_EXECUTABLE: ${US_RCC_EXECUTABLE}")

if(TARGET ${US_RCC_EXECUTABLE_NAME})
set(resource_compiler ${US_RCC_EXECUTABLE_NAME})
elseif(NOT resource_compiler)
Expand Down
159 changes: 159 additions & 0 deletions Code/CMake/CppMicroServices/usFunctionAddResources.cmake.modified
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#! \ingroup MicroServicesCMake
#! \brief Add resources to a library or executable.
#!
#! This CMake function uses an external command line program to generate a ZIP archive
#! containing data from external resources such as text files or images or other ZIP
#! archives. The created archive file can be appended or linked into the target file
#! using the usFunctionEmbedResources macro.
#!
#! Each module can call this function to add resources and make them available at
#! runtime through the Module class. Multiple calls to this function append the
#! input files.
#!
#! In the case of linking static modules which contain resources to the target module,
#! adding the static module target name to the ZIP_ARCHIVES list will merge its
#! resources into the target module.
#!
#! Example usage:
#! \code{.cmake}
#! set(module_srcs )
#! usFunctionAddResources(TARGET mylib
#! MODULE_NAME org_me_mylib
#! FILES config.properties logo.png
#! )
#! \endcode
#!
#! \param TARGET (required) The target to which the resource files are added.
#! \param MODULE_NAME (required/optional) The module name of the target, as specified in
#! the \c US_MODULE_NAME pre-processor definition of that target. This parameter
#! is optional if a target property with the name US_MODULE_NAME exists, containing
#! the required module name.
#! \param COMPRESSION_LEVEL (optional) The zip compression level (0-9). Defaults to the default zip
#! level. Level 0 disables compression.
#! \param WORKING_DIRECTORY (optional) The root path for all resource files listed after the
#! FILES argument. If no or a relative path is given, it is considered relativ to the
#! current CMake source directory.
#! \param FILES (optional) A list of resource files (paths to external files in the file system)
#! relative to the current working directory.
#! \param ZIP_ARCHIVES (optional) A list of zip archives (relative to the current working directory
#! or absolute file paths) whose contents is merged into the target module. If a list entry
#! is a valid target name and that target is a static library, its absolute file path is
#! used instead.
#!
#! \sa usFunctionEmbedResources
#! \sa \ref MicroServices_Resources
#!
function(usFunctionAddResources)

message(STATUS " ")
message(STATUS "================ usFunctionAddResources ============== ")

cmake_parse_arguments(US_RESOURCE "" "TARGET;MODULE_NAME;WORKING_DIRECTORY;COMPRESSION_LEVEL" "FILES;ZIP_ARCHIVES" ${ARGN})

if(NOT US_RESOURCE_TARGET)
message(SEND_ERROR "TARGET argument not specified.")
endif()

if(NOT US_RESOURCE_MODULE_NAME)
get_target_property(US_RESOURCE_MODULE_NAME ${US_RESOURCE_TARGET} US_MODULE_NAME)
if(NOT US_RESOURCE_MODULE_NAME)
message(SEND_ERROR "Either the MODULE_NAME argument or the US_MODULE_NAME target property is required.")
endif()
endif()

if(NOT US_RESOURCE_FILES AND NOT US_RESOURCE_ZIP_ARCHIVES)
message(WARNING "No resources specified. Skipping resource processing.")
return()
endif()

if(NOT US_RESOURCE_WORKING_DIRECTORY)
set(US_RESOURCE_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
if(NOT IS_ABSOLUTE ${US_RESOURCE_WORKING_DIRECTORY})
set(US_RESOURCE_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${US_RESOURCE_WORKING_DIRECTORY}")
endif()

if(US_RESOURCE_COMPRESSION_LEVEL)
set(cmd_line_args -${US_RESOURCE_COMPRESSION_LEVEL})
endif()

set(resource_compiler ${US_RCC_EXECUTABLE})
message(STATUS "[usFunctionAddResources] US_RCC_EXECUTABLE: ${US_RCC_EXECUTABLE}")

if(TARGET ${US_RCC_EXECUTABLE_NAME})
set(resource_compiler ${US_RCC_EXECUTABLE_NAME})
elseif(NOT resource_compiler)
message(FATAL_ERROR "The CppMicroServices resource compiler was not found. Check the US_RCC_EXECUTABLE CMake variable.")
endif()

set(_cmd_deps )
foreach(_file ${US_RESOURCE_FILES})
if(IS_ABSOLUTE ${_file})
list(APPEND _cmd_deps ${_file})
else()
list(APPEND _cmd_deps ${US_RESOURCE_WORKING_DIRECTORY}/${_file})
endif()
endforeach()

set(_zip_args )
if(US_RESOURCE_ZIP_ARCHIVES)
foreach(_zip_archive ${US_RESOURCE_ZIP_ARCHIVES})
if(TARGET ${_zip_archive})
get_target_property(_is_static_lib ${_zip_archive} TYPE)
if(_is_static_lib STREQUAL "STATIC_LIBRARY")
list(APPEND _cmd_deps ${_zip_archive})
list(APPEND _zip_args $<TARGET_FILE:${_zip_archive}>)
endif()
else()
if(IS_ABSOLUTE ${_zip_archive})
list(APPEND _cmd_deps ${_zip_archive})
else()
list(APPEND _cmd_deps ${US_RESOURCE_WORKING_DIRECTORY}/${_zip_archive})
endif()
list(APPEND _zip_args ${_zip_archive})
endif()
endforeach()
endif()

if(NOT US_RESOURCE_FILES AND NOT _zip_args)
return()
endif()

if(US_RESOURCE_FILES)
set(_file_args -a ${US_RESOURCE_FILES})
endif()
if(_zip_args)
set(_zip_args -m ${_zip_args})
endif()

get_target_property(_counter ${US_RESOURCE_TARGET} _us_resource_counter)
if((NOT ${_counter} EQUAL 0) AND NOT _counter)
set(_counter 0)
else()
math(EXPR _counter "${_counter} + 1")
endif()

set(_res_zip "${CMAKE_CURRENT_BINARY_DIR}/us_${US_RESOURCE_TARGET}/res_${_counter}.zip")

add_custom_command(
OUTPUT ${_res_zip}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/us_${US_RESOURCE_TARGET}"
COMMAND ${resource_compiler} ${cmd_line_args} ${_res_zip} ${US_RESOURCE_MODULE_NAME} ${_file_args} ${_zip_args}
WORKING_DIRECTORY ${US_RESOURCE_WORKING_DIRECTORY}
DEPENDS ${_cmd_deps} ${resource_compiler}
COMMENT "Checking resource dependencies for ${US_RESOURCE_TARGET}"
VERBATIM
)

get_target_property(_res_zips ${US_RESOURCE_TARGET} _us_resource_zips)
if(NOT _res_zips)
set(_res_zips )
endif()
list(APPEND _res_zips ${_res_zip})

set_target_properties(${US_RESOURCE_TARGET} PROPERTIES
_us_resource_counter "${_counter}"
_us_resource_zips "${_res_zips}"
)

endfunction()
2 changes: 2 additions & 0 deletions Code/CMake/Externals/Qt5.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
# Qt
set(proj Qt5)

message(FATAL_ERROR "====================== Qt5.cmake ==========")

if(SV_USE_${proj})
if(SV_EXTERNALS_USE_PREBUILT_QT)
set(Qt5_DIR ${SV_EXTERNALS_PREBUILT_QT_PATH} CACHE PATH "Force ${proj} dir to prebuilt Qt" FORCE)
Expand Down
Loading

0 comments on commit ec3724c

Please sign in to comment.