diff options
author | Martin Nowack <m.nowack@imperial.ac.uk> | 2019-03-13 13:30:13 +0000 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2019-03-17 15:43:21 +0000 |
commit | dccfb3d1b62f0c00e3e16547f3d9ec02de49be52 (patch) | |
tree | 327e597d11a84fe49e76bb12d6806ffddfcbda3a | |
parent | ae6da669e546d2ac0881da2c898c01f28b7ed7e2 (diff) | |
download | klee-dccfb3d1b62f0c00e3e16547f3d9ec02de49be52.tar.gz |
Cmake enhance detection of C++ libraries and include files
* Use directory instead of libc++ files * support `bca` and `ba` files * Add additional checks if directories exist
-rw-r--r-- | CMakeLists.txt | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d5830869..98bf07bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -618,24 +618,43 @@ option(ENABLE_KLEE_LIBCXX "Enable libcxx for klee" OFF) if (ENABLE_KLEE_LIBCXX) message(STATUS "klee-libcxx support enabled") set(SUPPORT_KLEE_LIBCXX 1) # For config.h - set(KLEE_LIBCXX_EXTERNAL_OBJECT "" CACHE PATH "Path to llvm libcxx shared object") - if (NOT EXISTS "${KLEE_LIBCXX_EXTERNAL_OBJECT}") + set(KLEE_LIBCXX_DIR "" CACHE PATH "Path to root directory with libcxx shared object") + if (NOT EXISTS "${KLEE_LIBCXX_DIR}") message(FATAL_ERROR - "${KLEE_LIBCXX_EXTERNAL_OBJECT} does not exist. Try passing -DKLEE_LIBCXX_EXTERNAL_OBJECT=<path>") + "${KLEE_LIBCXX_PATH} does not exist. Try passing -DKLEE_LIBCXX_DIR=<path>") endif() if (NOT IS_DIRECTORY "${KLEE_LIBCXX_INCLUDE_DIR}") message(FATAL_ERROR "${KLEE_LIBCXX_INCLUDE_DIR} does not exist. Try passing -DKLEE_LIBCXX_INCLUDE_DIR=<path>") endif() - - set(KLEE_LIBCXX_BC_NAME "libcxx.so.bc") + message(STATUS "Use libc++ include path: \"${KLEE_LIBCXX_INCLUDE_DIR}\"") + + # Find the library bitcode archive + + # Check for static first + set(KLEE_LIBCXX_BC_NAME "libc++.bca") + set(KLEE_LIBCXX_BC_PATH "${KLEE_LIBCXX_DIR}/lib/${KLEE_LIBCXX_BC_NAME}") + if (NOT EXISTS "${KLEE_LIBCXX_BC_PATH}") + # Check for dynamic so lib + set(KLEE_LIBCXX_BC_NAME "libc++.so.bc") + set(KLEE_LIBCXX_BC_PATH "${KLEE_LIBCXX_DIR}/lib/${KLEE_LIBCXX_BC_NAME}") + if (NOT EXISTS "${KLEE_LIBCXX_BC_PATH}") + set(KLEE_LIBCXX_BC_NAME "libc++.dylib.bc") + set(KLEE_LIBCXX_BC_PATH "${KLEE_LIBCXX_DIR}/lib/${KLEE_LIBCXX_BC_NAME}") + if (NOT EXISTS "${KLEE_LIBCXX_BC_PATH}") + message(FATAL_ERROR + "libc++ library not found at \"${KLEE_LIBCXX_DIR}\"") + endif() + endif() + endif() + message(STATUS "Found libc++ library: \"${KLEE_LIBCXX_BC_PATH}\"") # Make a symlink to KLEE_LIBCXX_EXTERNAL_OBJECT so KLEE can find it where it # is expected. file(MAKE_DIRECTORY "${KLEE_RUNTIME_DIRECTORY}") execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink - "${KLEE_LIBCXX_EXTERNAL_OBJECT}" + "${KLEE_LIBCXX_BC_PATH}" "${KLEE_RUNTIME_DIRECTORY}/${KLEE_LIBCXX_BC_NAME}" ) list(APPEND KLEE_COMPONENT_CXX_DEFINES @@ -644,13 +663,13 @@ if (ENABLE_KLEE_LIBCXX) # Add libcxx to the install target. We install the original # file rather than the symlink because CMake would just copy the symlink # rather than the file. - install(FILES "${KLEE_LIBCXX_EXTERNAL_OBJECT}" + install(FILES "${KLEE_LIBCXX_BC_PATH}" DESTINATION "${KLEE_INSTALL_RUNTIME_DIR}" RENAME "${KLEE_LIBCXX_BC_NAME}" ) else() - message(STATUS "libcxx support disabled") + message(STATUS "libc++ support disabled") set(SUPPORT_KLEE_LIBCXX 0) # For config.h endif() |