1- cmake_minimum_required (VERSION 3.16.2 )
1+ # 3.23 Required for proxTV FILE_SETS
2+ cmake_minimum_required (VERSION 3.23.0 )
23project (TotalVariation)
34
4- if (ITK_USE_SYSTEM_proxTV)
5- set (TotalVariation_LIBRARIES proxTV::proxTV)
6- else ()
7- set (TotalVariation_LIBRARIES proxTV)
8- endif ()
95
10- set (${PROJECT_NAME} _THIRD_PARTY 1)
6+ set (TotalVariation_LIBRARIES proxTV::proxTV)
7+
118
129include (itk-module-init.cmake )
1310
@@ -16,62 +13,29 @@ if(NOT ITK_SOURCE_DIR)
1613 list (APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR} )
1714endif ()
1815
19- include (CMakeParseArguments )
2016include (FetchContent )
2117
22- # Compile definition needed for proxTV headers
23- # This will propagate to wrapping.
24- # For wrapping to work, requires ITK with patch:
25- # https://github.com/InsightSoftwareConsortium/ITK/pull/707
26- add_compile_definitions (NOMATLAB )
27-
2818message (STATUS "TotalVariation_proxTV_USE_EIGEN: ${TotalVariation_proxTV_USE_EIGEN} " )
29- if (TotalVariation_proxTV_USE_EIGEN)
30- if (NOT ITK_USE_SYSTEM_EIGEN)
31- # Set Eigen3_DIR to the internal Eigen3 used in ITK
32- set (Eigen3_DIR "${ITKInternalEigen3_DIR} " )
33- message (STATUS "ITKTotalVariation: Using internal ITK Eigen Config found in: ${Eigen3_DIR} " )
34- endif ()
35- find_package (Eigen3 REQUIRED )
36- set (${PROJECT_NAME} _EXPORT_CODE_INSTALL
37- "${${PROJECT_NAME} _EXPORT_CODE_INSTALL}
38- find_package(OpenMP)
39- set(Eigen3_DIR \" ${Eigen3_DIR} \" )
40- find_package(Eigen3 REQUIRED CONFIG)
41- " )
42- set (${PROJECT_NAME} _EXPORT_CODE_BUILD
43- "${${PROJECT_NAME} _EXPORT_CODE_BUILD}
44- if(NOT ITK_BINARY_DIR)
45- find_package(OpenMP)
46- set(Eigen3_DIR \" ${Eigen3_DIR} \" )
47- find_package(Eigen3 REQUIRED CONFIG)
48- endif()
49- " )
50- else ()
51- # proxTV will be build with external system LAPACK instead of Eigen3
52- set (proxTV_USE_LAPACK 1)
53- add_compile_definitions (PROXTV_USE_LAPACK )
54- endif ()
5519
56- # _proxTV_lib will be `proxTV::proxTV` when find_package, and `proxTV` when add_subdirectory(proxTV_folder)
57- set (_proxTV_lib "" )
5820# if proxTV is built elsewhere
5921if (ITK_USE_SYSTEM_proxTV)
6022 find_package (proxTV REQUIRED CONFIG )
61- set (_proxTV_lib proxTV::proxTV)
62- set (proxTV_DIR_INSTALL ${proxTV_DIR} )
63- set (proxTV_DIR_BUILD ${proxTV_DIR} )
64- # It is only needed to EXPORT_CODE_BUILD when using external proxTV
23+
24+ # It is needed to EXPORT_CODE_BUILD when using external proxTV
6525 set (${PROJECT_NAME} _EXPORT_CODE_BUILD
6626"${${PROJECT_NAME} _EXPORT_CODE_BUILD}
6727if(NOT ITK_BINARY_DIR)
68- find_package(OpenMP)
69- set(proxTV_DIR \" ${proxTV_DIR_BUILD} \" )
7028 find_package(proxTV REQUIRED CONFIG)
7129endif()
7230" )
31+ # When this module is loaded by an app, it is needed to find proxTV and OpenMP
32+ set (${PROJECT_NAME} _EXPORT_CODE_INSTALL
33+ "${${PROJECT_NAME} _EXPORT_CODE_INSTALL}
34+ find_package(proxTV REQUIRED CONFIG)
35+ " )
36+
7337else () # build proxTV here with the selected Eigen3
74- # Build proxTV with C++11
38+ # Build proxTV with C++14
7539 if (NOT CMAKE_CXX_STANDARD )
7640 set (CMAKE_CXX_STANDARD 14)
7741 endif ()
@@ -82,63 +46,43 @@ else() # build proxTV here with the selected Eigen3
8246 set (CMAKE_CXX_EXTENSIONS OFF )
8347 endif ()
8448
49+ set (proxTV_Eigen_LIBRARIES ITK::ITKEigen3Module)
50+
8551 set (proxTV_GIT_REPOSITORY "https://github.com/phcerdan/proxTV.git" )
86- set (proxTV_GIT_TAG "use_eigen " )
52+ set (proxTV_GIT_TAG "itk_installation " )
8753 FetchContent_Declare (
8854 proxtv_fetch
8955 GIT_REPOSITORY ${proxTV_GIT_REPOSITORY}
90- GIT_TAG ${proxTV_GIT_TAG} )
91- FetchContent_GetProperties (proxTV_fetch)
56+ GIT_TAG ${proxTV_GIT_TAG}
57+ )
58+
9259 # proxTV options:
93- set (Eigen3_DIR "${Eigen3_DIR} " ) # This is not needed but explicit helps reader.
94- set (proxTV_USE_LAPACK 0)
95- if (NOT DEFINED proxTV_INSTALL_INCLUDE_DIR)
96- if (NOT ITK_SOURCE_DIR )
97- set (ITK_INSTALL_INCLUDE_DIR include/ITK-${ITK_VERSION_MAJOR} .${ITK_VERSION_MINOR} )
98- endif ()
99- set (proxTV_INSTALL_INCLUDE_DIR ${ITK_INSTALL_INCLUDE_DIR} /proxTV)
100- endif ()
101- if (NOT DEFINED proxTV_INSTALL_LIB_DIR)
102- if (NOT ITK_SOURCE_DIR )
103- set (ITK_INSTALL_LIBRARY_DIR lib)
104- endif ()
105- set (proxTV_INSTALL_LIB_DIR ${ITK_INSTALL_LIBRARY_DIR} )
106- endif ()
107- if (NOT DEFINED proxTV_INSTALL_CMAKE_DIR)
108- if (NOT ITK_SOURCE_DIR )
109- set (ITK_INSTALL_PACKAGE_DIR "lib/cmake/ITK-${ITK_VERSION_MAJOR} .${ITK_VERSION_MINOR} " )
110- endif ()
111- set (proxTV_INSTALL_CMAKE_DIR ${ITK_INSTALL_PACKAGE_DIR} /Modules)
60+ if (TotalVariation_proxTV_USE_EIGEN)
61+ set (proxTV_USE_LAPACK 0)
62+ else ()
63+ set (proxTV_USE_LAPACK 1)
11264 endif ()
65+
11366 # end proxTV options
11467
11568 FetchContent_MakeAvailable (proxTV_fetch)
116- # proxTV will generate a target proxTV::proxTV when using find_package,
117- # or a library proxTV when using add_subdirectory
118- set (_proxTV_lib proxTV) # proxTV generated in subdirectory
119- set (proxTV_DIR_INSTALL "${CMAKE_INSTALL_PREFIX} /${proxTV_INSTALL_CMAKE_DIR} " )
120- endif ()
12169
122- # When this module is loaded by an app, load proxTV too.
123- set (${PROJECT_NAME} _EXPORT_CODE_INSTALL
124- "${${PROJECT_NAME} _EXPORT_CODE_INSTALL}
125- find_package(OpenMP)
126- set(proxTV_DIR \" ${proxTV_DIR_INSTALL} \" )
127- find_package(proxTV REQUIRED CONFIG)
70+ if (proxTV_USE_LAPACK)
71+ set (${PROJECT_NAME} _EXPORT_CODE_BUILD
72+ "${${PROJECT_NAME} _EXPORT_CODE_BUILD}
73+ if(NOT ITK_BINARY_DIR)
74+ find_package(LAPACKE REQUIRED)
75+ find_package(LAPACK REQUIRED)
76+ endif()
12877" )
78+ set (${PROJECT_NAME} _EXPORT_CODE_INSTALL
79+ "${${PROJECT_NAME} _EXPORT_CODE_INSTALL}
80+ find_package(LAPACKE REQUIRED)
81+ find_package(LAPACK REQUIRED)
82+ " )
83+ endif ()
12984
130- set (_populate_include_dirs_for_swig TRUE )
131- if (${_populate_include_dirs_for_swig} )
132- # SWIG (wrapping) requires INCLUDE_DIRS
133- get_target_property (proxTV_INCLUDE_DIRS ${_proxTV_lib} INTERFACE_INCLUDE_DIRECTORIES )
134- string (REGEX REPLACE
135- ".*BUILD_INTERFACE:(.*/proxtv_fetch-build/src/include).*"
136- "\\ 1"
137- proxTV_INCLUDE_DIRS_STRIP
138- ${proxTV_INCLUDE_DIRS} )
139- # message(STATUS "proxTV_INCLUDE_DIRS: ${proxTV_INCLUDE_DIRS}")
140- # message(STATUS "proxTV_INCLUDE_DIRS_STRIP: ${proxTV_INCLUDE_DIRS_STRIP}")
141- set (TotalVariation_INCLUDE_DIRS ${proxTV_INCLUDE_DIRS_STRIP} )
85+ itk_module_target (proxTV NAMESPACE proxTV:: )
14286endif ()
14387
14488
@@ -151,5 +95,3 @@ else()
15195endif ()
15296
15397
154- # Add the proxTV library to Modules/Targets/TotalVariationTargets.cmake
155- itk_module_target (${_proxTV_lib} NO_INSTALL )
0 commit comments