Skip to content

Commit 271731e

Browse files
ldionnetru
authored andcommitted
[libc++] Fix a few incorrect CMake configuration options
This patch fixes a few CMake options that were set using incorrect mechanisms. CMake's man page for the -D <var>=<value> option states: If a command in the project sets the type to PATH or FILEPATH, then the <value> will be converted to an absolute path. That's not what we want for most of the paths we have as configuration options. Otherwise, using -D to set the configuration option results in an absolute path being used, which breaks things. option() denotes a boolean variable, but what was desired was a string/list variable. Fix this to prevent cmake from changing any non-empty user provided values to 'ON'. Differential Revision: https://reviews.llvm.org/D157926 (cherry picked from commit 760261a)
1 parent db0bf3b commit 271731e

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

libcxx/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ if (NOT ("${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}" IN_LIST TYPEINFO_COMPARI
197197
endif()
198198

199199
set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.")
200-
option(LIBCXX_EXTRA_SITE_DEFINES "Extra defines to add into __config_site")
200+
set(LIBCXX_EXTRA_SITE_DEFINES "" CACHE STRING "Extra defines to add into __config_site")
201201
option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
202202

203203
# ABI Library options ---------------------------------------------------------
@@ -384,9 +384,9 @@ endif ()
384384
# TODO: Projects that depend on libc++ should use LIBCXX_GENERATED_INCLUDE_DIR
385385
# instead of hard-coding include/c++/v1.
386386

387-
set(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH
387+
set(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE STRING
388388
"Path where target-agnostic libc++ headers should be installed.")
389-
set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
389+
set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
390390
"Path where built libc++ runtime libraries should be installed.")
391391

392392
set(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output name for the shared libc++ runtime library.")
@@ -397,9 +397,9 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
397397
set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
398398
set(LIBCXX_GENERATED_MODULE_DIR "${LLVM_BINARY_DIR}/modules/c++/v1")
399399
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
400-
set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
400+
set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE STRING
401401
"Path where built libc++ libraries should be installed.")
402-
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH
402+
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE STRING
403403
"Path where target-specific libc++ headers should be installed.")
404404
if(LIBCXX_LIBDIR_SUBDIR)
405405
string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})
@@ -416,9 +416,9 @@ else()
416416
set(LIBCXX_GENERATED_MODULE_DIR "${CMAKE_BINARY_DIR}/modules/c++/v1")
417417
endif()
418418
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
419-
set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH
419+
set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE STRING
420420
"Path where built libc++ libraries should be installed.")
421-
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH
421+
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE STRING
422422
"Path where target-specific libc++ headers should be installed.")
423423
endif()
424424

libcxxabi/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ option(LIBCXXABI_INSTALL_LIBRARY "Install the libc++abi library." ON)
8080
set(LIBCXXABI_SHARED_OUTPUT_NAME "c++abi" CACHE STRING "Output name for the shared libc++abi runtime library.")
8181
set(LIBCXXABI_STATIC_OUTPUT_NAME "c++abi" CACHE STRING "Output name for the static libc++abi runtime library.")
8282

83-
set(LIBCXXABI_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH "Path to install the libc++abi headers at.")
83+
set(LIBCXXABI_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE STRING "Path to install the libc++abi headers at.")
8484

8585
if(LLVM_LIBRARY_OUTPUT_INTDIR)
8686
set(LIBCXXABI_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
@@ -182,13 +182,13 @@ set(CMAKE_MODULE_PATH
182182
${CMAKE_MODULE_PATH}
183183
)
184184

185-
set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
185+
set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
186186
"Path where built libc++abi runtime libraries should be installed.")
187187

188188
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
189189
set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
190190
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
191-
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
191+
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE STRING
192192
"Path where built libc++abi libraries should be installed.")
193193
if(LIBCXX_LIBDIR_SUBDIR)
194194
string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
@@ -202,7 +202,7 @@ else()
202202
set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
203203
set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
204204
endif()
205-
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
205+
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE STRING
206206
"Path where built libc++abi libraries should be installed.")
207207
endif()
208208

0 commit comments

Comments
 (0)