Skip to content

Commit 4b4b94e

Browse files
blowekampmalaterre
authored andcommitted
ENH: Conform GDCM to support CMAKE_*OUTPUT_DIRECTORY
Recommend users using modern CMAKE_*_OUTPUT_DIRECTORY variables to configure paths. Prioritize legacy variables only if set by the user. Removes setting legacy CMake variable such as EXECUTE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH as cache variables. Add support for modern CMAKE_*_OUTPUT_DIRECTORY variables, if they are set by the user.
1 parent 0393310 commit 4b4b94e

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

CMakeLists.txt

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,39 @@ if(BUILD_SHARED_LIBS)
118118
endif()
119119

120120
#-----------------------------------------------------------------------------
121-
if(NOT EXECUTABLE_OUTPUT_PATH)
122-
set(EXECUTABLE_OUTPUT_PATH ${GDCM_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
123-
mark_as_advanced(EXECUTABLE_OUTPUT_PATH)
121+
# Compatibility with older usage of EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH.
122+
# This should be removed in the future.
123+
if(EXECUTABLE_OUTPUT_PATH)
124+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
125+
message(WARNING "EXECUTABLE_OUTPUT_PATH is deprecated. Use CMAKE_RUNTIME_OUTPUT_DIRECTORY instead.")
124126
endif()
125-
if(NOT LIBRARY_OUTPUT_PATH)
126-
set(LIBRARY_OUTPUT_PATH ${GDCM_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
127-
mark_as_advanced(LIBRARY_OUTPUT_PATH)
127+
if(LIBRARY_OUTPUT_PATH)
128+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH})
129+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH})
130+
message(WARNING "LIBRARY_OUTPUT_PATH is deprecated. Use CMAKE_LIBRARY_OUTPUT_DIRECTORY and CMAKE_ARCHIVE_OUTPUT_DIRECTORY instead.")
128131
endif()
129132

130-
# TODO: The following should be used for CMake 3 and beyond,
131-
# EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH are deprecated
132-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
133-
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH})
134-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH})
133+
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
134+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
135+
endif()
136+
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
137+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
138+
endif()
139+
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
140+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
141+
endif()
142+
143+
# Set for legacy internal usage of EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH
144+
if (NOT EXECUTABLE_OUTPUT_PATH)
145+
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
146+
endif()
147+
if (NOT LIBRARY_OUTPUT_PATH)
148+
if (BUILD_SHARED_LIBS)
149+
set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
150+
else()
151+
set(LIBRARY_OUTPUT_PATH ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
152+
endif()
153+
endif()
135154

136155
#-----------------------------------------------------------------------------
137156
# Adding GDCM_DATA_ROOT

0 commit comments

Comments
 (0)