Skip to content

Commit f5af295

Browse files
authored
Merge pull request #1946 from ANTsX/install_bin_only
Optionally install binaries only
2 parents 4013e80 + 30b5655 commit f5af295

File tree

6 files changed

+71
-26
lines changed

6 files changed

+71
-26
lines changed

.github/workflows/release-binaries.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ jobs:
9191
-DBUILD_TESTING=ON \
9292
-DRUN_SHORT_TESTS=ON \
9393
-DRUN_LONG_TESTS=OFF \
94+
-DANTS_INSTALL_BIN_ONLY=ON \
9495
-DCMAKE_INSTALL_PREFIX:PATH=${{ runner.temp }}/install/ants-${{ env.ANTS_VERSION }} \
9596
${GITHUB_WORKSPACE}
9697
- name: Build

.github/workflows/release-docker-binaries.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ jobs:
127127
-DBUILD_TESTING=ON \
128128
-DRUN_SHORT_TESTS=ON \
129129
-DRUN_LONG_TESTS=OFF \
130+
-DANTS_INSTALL_BIN_ONLY=ON \
130131
-DCMAKE_INSTALL_PREFIX:PATH=/workspace/install/ants-${{ env.ANTS_VERSION }} \
131132
/workspace
132133
"

.github/workflows/release-win-binaries.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
-DBUILD_TESTING=ON `
5252
-DRUN_SHORT_TESTS=ON `
5353
-DRUN_LONG_TESTS=OFF `
54+
-DANTS_INSTALL_BIN_ONLY=ON `
5455
-DCMAKE_INSTALL_PREFIX:PATH=${{ runner.temp }}/install/ants-${{ env.ANTS_VERSION }} `
5556
${{ github.workspace }}
5657
- name: Build

ANTS.cmake

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ include(${ITK_USE_FILE})
4444
# Set up which ANTs apps to build
4545
option(BUILD_ALL_ANTS_APPS "Use All ANTs Apps" ON)
4646

47+
# -------------------------------------------------------------------------
48+
# Install options
49+
# -------------------------------------------------------------------------
50+
option(ANTS_INSTALL_BIN_ONLY "Install only ANTs executables + scripts (bin/). Requires BUILD_SHARED_LIBS=OFF." OFF)
51+
mark_as_advanced(ANTS_INSTALL_BIN_ONLY)
52+
53+
if(ANTS_INSTALL_BIN_ONLY AND ANTS_INSTALL_LIBS_ONLY)
54+
message(FATAL_ERROR "ANTS_INSTALL_BIN_ONLY and ANTS_INSTALL_LIBS_ONLY are mutually exclusive.")
55+
endif()
56+
57+
if(ANTS_INSTALL_BIN_ONLY AND BUILD_SHARED_LIBS)
58+
message(FATAL_ERROR "ANTS_INSTALL_BIN_ONLY requires BUILD_SHARED_LIBS=OFF (static build).")
59+
endif()
60+
4761
# Set up VTK
4862
option(USE_VTK "Use VTK Libraries" OFF)
4963
if(USE_VTK)
@@ -132,7 +146,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ANTsVersionConfig.h.in"
132146

133147
add_subdirectory(Examples)
134148

135-
if (NOT ANTS_INSTALL_LIBS_ONLY)
149+
if (NOT ANTS_INSTALL_LIBS_ONLY)
136150
install(PROGRAMS Scripts/ANTSpexec.sh
137151
Scripts/antsASLProcessing.sh
138152
Scripts/antsAtroposN4.sh

Examples/CMakeLists.txt

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ add_library(antsUtilities antsUtilities.cxx
1313
ImageMathHelper2D.cxx ImageMathHelper3D.cxx ImageMathHelper4D.cxx
1414
)
1515
target_link_libraries(antsUtilities ${ITK_LIBRARIES} )
16-
install(TARGETS antsUtilities
17-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
18-
COMPONENT RUNTIME_antsUtilities
19-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
20-
COMPONENT RUNTIME_antsUtilities
21-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
22-
COMPONENT DEVELOPMENT_antsUtilities
23-
)
24-
16+
if (NOT ANTS_INSTALL_BIN_ONLY)
17+
install(TARGETS antsUtilities
18+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
19+
COMPONENT RUNTIME_antsUtilities
20+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
21+
COMPONENT RUNTIME_antsUtilities
22+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
23+
COMPONENT DEVELOPMENT_antsUtilities
24+
)
25+
endif()
2526
macro(STATIC_ANTS_BUILD ANTS_FUNCTION_NAME EXTRA_LIBS)
2627
set( ANTS_FUNCTION_NAME ${ANTS_FUNCTION_NAME} )
2728

@@ -44,14 +45,23 @@ macro(STATIC_ANTS_BUILD ANTS_FUNCTION_NAME EXTRA_LIBS)
4445
else()
4546
add_executable( ${ANTS_FUNCTION_NAME} cli_${ANTS_FUNCTION_NAME}.cxx )
4647
target_link_libraries( ${ANTS_FUNCTION_NAME} l_${ANTS_FUNCTION_NAME} )
47-
install(TARGETS l_${ANTS_FUNCTION_NAME} ${ANTS_FUNCTION_NAME}
48-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
49-
COMPONENT RUNTIME_${ANTS_FUNCTION_NAME}
50-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
51-
COMPONENT RUNTIME_${ANTS_FUNCTION_NAME}
52-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
53-
COMPONENT DEVELOPMENT_${ANTS_FUNCTION_NAME}
54-
)
48+
49+
if (ANTS_INSTALL_BIN_ONLY)
50+
# Install only the executable (no libs/archives)
51+
install(TARGETS ${ANTS_FUNCTION_NAME}
52+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
53+
COMPONENT RUNTIME_${ANTS_FUNCTION_NAME}
54+
)
55+
else()
56+
install(TARGETS l_${ANTS_FUNCTION_NAME} ${ANTS_FUNCTION_NAME}
57+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
58+
COMPONENT RUNTIME_${ANTS_FUNCTION_NAME}
59+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
60+
COMPONENT RUNTIME_${ANTS_FUNCTION_NAME}
61+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
62+
COMPONENT DEVELOPMENT_${ANTS_FUNCTION_NAME}
63+
)
64+
endif()
5565
endif()
5666

5767
endmacro()
@@ -79,14 +89,21 @@ macro(DYNAMIC_ANTS_BUILD ANTS_FUNCTION_NAME EXTRA_LIBS)
7989
add_executable( ${ANTS_FUNCTION_NAME} cli_${ANTS_FUNCTION_NAME}.cxx )
8090
target_link_libraries( ${ANTS_FUNCTION_NAME} l_${ANTS_FUNCTION_NAME} )
8191

82-
install(TARGETS l_${ANTS_FUNCTION_NAME} ${ANTS_FUNCTION_NAME}
83-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
84-
COMPONENT RUNTIME_${ANTS_FUNCTION_NAME}
85-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
86-
COMPONENT RUNTIME_${ANTS_FUNCTION_NAME}
87-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
88-
COMPONENT DEVELOPMENT_${ANTS_FUNCTION_NAME}
89-
)
92+
if (ANTS_INSTALL_BIN_ONLY)
93+
install(TARGETS ${ANTS_FUNCTION_NAME}
94+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
95+
COMPONENT RUNTIME_${ANTS_FUNCTION_NAME}
96+
)
97+
else()
98+
install(TARGETS l_${ANTS_FUNCTION_NAME} ${ANTS_FUNCTION_NAME}
99+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
100+
COMPONENT RUNTIME_${ANTS_FUNCTION_NAME}
101+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
102+
COMPONENT RUNTIME_${ANTS_FUNCTION_NAME}
103+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
104+
COMPONENT DEVELOPMENT_${ANTS_FUNCTION_NAME}
105+
)
106+
endif()
90107
endif()
91108

92109
endmacro()

SuperBuild.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,19 @@ option(RUN_SHORT_TESTS "Run the quick unit tests."
111111
option(RUN_LONG_TESTS "Run the time consuming tests. i.e. real world registrations" ON )
112112
option(OLD_BASELINE_TESTS "Use reported metrics from old tests" OFF )
113113

114+
option(ANTS_INSTALL_BIN_ONLY "Do not install libraries (requires static build)" OFF)
114115
option(ANTS_INSTALL_LIBS_ONLY "Do not install binaries" OFF)
116+
mark_as_advanced(ANTS_INSTALL_BIN_ONLY)
115117
mark_as_advanced(ANTS_INSTALL_LIBS_ONLY)
116118

119+
if(ANTS_INSTALL_BIN_ONLY AND BUILD_SHARED_LIBS)
120+
message(FATAL_ERROR "ANTS_INSTALL_BIN_ONLY requires BUILD_SHARED_LIBS=OFF (static build).")
121+
endif()
122+
123+
if(ANTS_INSTALL_BIN_ONLY AND ANTS_INSTALL_LIBS_ONLY)
124+
message(FATAL_ERROR "ANTS_INSTALL_BIN_ONLY and ANTS_INSTALL_LIBS_ONLY are mutually exclusive.")
125+
endif()
126+
117127
#------------------------------------------------------------------------------
118128
# ${LOCAL_PROJECT_NAME} dependency list
119129
#------------------------------------------------------------------------------
@@ -261,6 +271,7 @@ list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS
261271
RUN_SHORT_TESTS:BOOL
262272
RUN_LONG_TESTS:BOOL
263273
OLD_BASELINE_TESTS:BOOL
274+
ANTS_INSTALL_BIN_ONLY:BOOL
264275
ANTS_INSTALL_LIBS_ONLY:BOOL
265276

266277
# PAC - ANTS and ITK both include ITKSetStandardCompilerFlags.cmake, which will set optimization flags unless

0 commit comments

Comments
 (0)