Skip to content

Commit f4825db

Browse files
RahulHereRahulHere
authored andcommitted
Fix CMAKE_INSTALL_PREFIX to respect user-specified values
The previous code unconditionally set CMAKE_INSTALL_PREFIX, which overrode any command-line -DCMAKE_INSTALL_PREFIX=... settings. This caused Docker builds to install to the wrong directory. Now uses CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT to only set the default when the user hasn't specified a custom install prefix.
1 parent 582e649 commit f4825db

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ if(NOT CMAKE_BUILD_TYPE)
8383
set(CMAKE_BUILD_TYPE Debug)
8484
endif()
8585

86-
# Set custom install prefix
87-
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/install_prefix_dir")
86+
# Set custom install prefix (only if not specified by user)
87+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
88+
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/install_prefix_dir" CACHE PATH "Install prefix" FORCE)
89+
endif()
8890

8991
#Compiler flags
9092
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")

0 commit comments

Comments
 (0)