Commit 672f1c81 authored by Pavel Kretov's avatar Pavel Kretov Committed by Dominik Charousset

Make consistent use of CMAKE_CURRENT_*_DIR

CMakeLists.txt used CMAKE_CURRENT_SOURCE_DIR in some cases, but
CMAKE_SOURCE_DIR in others, which made it impossible to include CAF into
another project by using CMake's `add_subdirectory` command.
parent 81301514
...@@ -51,7 +51,7 @@ set(CAF_VERSION ...@@ -51,7 +51,7 @@ set(CAF_VERSION
################################################################################ ################################################################################
# prohibit in-source builds # prohibit in-source builds
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed. Please use " message(FATAL_ERROR "In-source builds are not allowed. Please use "
"./configure to choose a build directory and " "./configure to choose a build directory and "
"initialize the build configuration.") "initialize the build configuration.")
...@@ -60,14 +60,14 @@ endif() ...@@ -60,14 +60,14 @@ endif()
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# set binary output path if not defined by user # set binary output path if not defined by user
if("${EXECUTABLE_OUTPUT_PATH}" STREQUAL "") if("${EXECUTABLE_OUTPUT_PATH}" STREQUAL "")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin") set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/bin")
endif() endif()
# set library output path if not defined by user, but always set # set library output path if not defined by user, but always set
# library output path to binary output path for Xcode projects # library output path to binary output path for Xcode projects
if("${CMAKE_GENERATOR}" STREQUAL "Xcode") if("${CMAKE_GENERATOR}" STREQUAL "Xcode")
set(LIBRARY_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}") set(LIBRARY_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}")
elseif("${LIBRARY_OUTPUT_PATH}" STREQUAL "") elseif("${LIBRARY_OUTPUT_PATH}" STREQUAL "")
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib") set(LIBRARY_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/lib")
endif() endif()
...@@ -79,7 +79,7 @@ endif() ...@@ -79,7 +79,7 @@ endif()
if(NOT WIN32 AND NOT NO_COMPILER_CHECK) if(NOT WIN32 AND NOT NO_COMPILER_CHECK)
try_run(ProgramResult try_run(ProgramResult
CompilationSucceeded CompilationSucceeded
"${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/get_compiler_version.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/get_compiler_version.cpp"
RUN_OUTPUT_VARIABLE CompilerVersion) RUN_OUTPUT_VARIABLE CompilerVersion)
if(NOT CompilationSucceeded OR NOT ProgramResult EQUAL 0) if(NOT CompilationSucceeded OR NOT ProgramResult EQUAL 0)
...@@ -147,7 +147,7 @@ if(NOT NO_AUTO_LIBCPP AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") ...@@ -147,7 +147,7 @@ if(NOT NO_AUTO_LIBCPP AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++") set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")
try_run(ProgramResult try_run(ProgramResult
CompilationSucceeded CompilationSucceeded
"${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/get_compiler_version.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/get_compiler_version.cpp"
RUN_OUTPUT_VARIABLE CompilerVersion) RUN_OUTPUT_VARIABLE CompilerVersion)
if(NOT CompilationSucceeded OR NOT ProgramResult EQUAL 0) if(NOT CompilationSucceeded OR NOT ProgramResult EQUAL 0)
...@@ -167,7 +167,7 @@ if(ENABLE_ADDRESS_SANITIZER) ...@@ -167,7 +167,7 @@ if(ENABLE_ADDRESS_SANITIZER)
set(CMAKE_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer")
try_run(ProgramResult try_run(ProgramResult
CompilationSucceeded CompilationSucceeded
"${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/get_compiler_version.cpp") "${CMAKE_CURRENT_SOURCE_DIR}/cmake/get_compiler_version.cpp")
if(NOT CompilationSucceeded) if(NOT CompilationSucceeded)
message(WARNING "Address Sanitizer is not available on selected compiler") message(WARNING "Address Sanitizer is not available on selected compiler")
...@@ -256,7 +256,7 @@ install(DIRECTORY libcaf_core/cppa/ ...@@ -256,7 +256,7 @@ install(DIRECTORY libcaf_core/cppa/
install(DIRECTORY libcaf_io/caf/ DESTINATION include/caf install(DIRECTORY libcaf_io/caf/ DESTINATION include/caf
FILES_MATCHING PATTERN "*.hpp") FILES_MATCHING PATTERN "*.hpp")
# install includes from opencl # install includes from opencl
if(EXISTS "${CMAKE_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt")
install(DIRECTORY libcaf_opencl/caf/ DESTINATION include/caf install(DIRECTORY libcaf_opencl/caf/ DESTINATION include/caf
FILES_MATCHING PATTERN "*.hpp") FILES_MATCHING PATTERN "*.hpp")
endif() endif()
...@@ -277,12 +277,12 @@ add_custom_target(uninstall ...@@ -277,12 +277,12 @@ add_custom_target(uninstall
# path to caf core & io headers # path to caf core & io headers
set(LIBCAF_INCLUDE_DIRS set(LIBCAF_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/libcaf_core" "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_core"
"${CMAKE_SOURCE_DIR}/libcaf_io") "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_io")
# path to caf opencl headers # path to caf opencl headers
if(EXISTS "${CMAKE_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt")
set(LIBCAF_INCLUDE_DIRS set(LIBCAF_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/libcaf_opencl/" "${LIBCAF_INCLUDE_DIRS}") "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/" "${LIBCAF_INCLUDE_DIRS}")
endif() endif()
# all projects need the headers of the core components # all projects need the headers of the core components
include_directories("${LIBCAF_INCLUDE_DIRS}") include_directories("${LIBCAF_INCLUDE_DIRS}")
...@@ -310,7 +310,8 @@ else() ...@@ -310,7 +310,8 @@ else()
set(LIBCAF_IO_LIBRARY libcaf_io_static) set(LIBCAF_IO_LIBRARY libcaf_io_static)
endif() endif()
# set opencl lib for sub directories if not told otherwise # set opencl lib for sub directories if not told otherwise
if(NOT CAF_NO_OPENCL AND EXISTS "${CMAKE_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt") if(NOT CAF_NO_OPENCL
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt")
message(STATUS "Enter subdirectory libcaf_opencl") message(STATUS "Enter subdirectory libcaf_opencl")
find_package(OPENCL REQUIRED) find_package(OPENCL REQUIRED)
add_subdirectory(libcaf_opencl) add_subdirectory(libcaf_opencl)
...@@ -332,7 +333,8 @@ if(NOT CAF_NO_UNIT_TESTS) ...@@ -332,7 +333,8 @@ if(NOT CAF_NO_UNIT_TESTS)
message(STATUS "Enter subdirectory unit_testing") message(STATUS "Enter subdirectory unit_testing")
add_subdirectory(unit_testing) add_subdirectory(unit_testing)
add_dependencies(all_unit_tests libcaf_core libcaf_io) add_dependencies(all_unit_tests libcaf_core libcaf_io)
if(NOT CAF_NO_OPENCL AND EXISTS "${CMAKE_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt") if(NOT CAF_NO_OPENCL
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt")
add_subdirectory(libcaf_opencl/unit_testing) add_subdirectory(libcaf_opencl/unit_testing)
endif() endif()
endif() endif()
...@@ -341,13 +343,15 @@ if(NOT CAF_NO_EXAMPLES) ...@@ -341,13 +343,15 @@ if(NOT CAF_NO_EXAMPLES)
message(STATUS "Enter subdirectory examples") message(STATUS "Enter subdirectory examples")
add_subdirectory(examples) add_subdirectory(examples)
add_dependencies(all_examples libcaf_core libcaf_io) add_dependencies(all_examples libcaf_core libcaf_io)
if(NOT CAF_NO_OPENCL AND EXISTS "${CMAKE_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt") if(NOT CAF_NO_OPENCL
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt")
add_subdirectory(libcaf_opencl/examples) add_subdirectory(libcaf_opencl/examples)
add_dependencies(opencl_examples libcaf_opencl) add_dependencies(opencl_examples libcaf_opencl)
endif() endif()
endif() endif()
# build RIAC if not being told otherwise # build RIAC if not being told otherwise
if(NOT CAF_NO_RIAC AND EXISTS "${CMAKE_SOURCE_DIR}/libcaf_riac/CMakeLists.txt") if(NOT CAF_NO_RIAC
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_riac/CMakeLists.txt")
message(STATUS "Enter subdirectory probe") message(STATUS "Enter subdirectory probe")
add_subdirectory(libcaf_riac) add_subdirectory(libcaf_riac)
add_dependencies(libcaf_riac libcaf_core libcaf_io) add_dependencies(libcaf_riac libcaf_core libcaf_io)
...@@ -357,14 +361,16 @@ if(NOT CAF_NO_RIAC AND EXISTS "${CMAKE_SOURCE_DIR}/libcaf_riac/CMakeLists.txt") ...@@ -357,14 +361,16 @@ if(NOT CAF_NO_RIAC AND EXISTS "${CMAKE_SOURCE_DIR}/libcaf_riac/CMakeLists.txt")
set(LIBCAF_LIBRARIES "${LIBCAF_LIBRARIES}" libcaf_riac_static) set(LIBCAF_LIBRARIES "${LIBCAF_LIBRARIES}" libcaf_riac_static)
endif() endif()
# add headers to include directories so other subprojects can use RIAC # add headers to include directories so other subprojects can use RIAC
include_directories("${LIBCAF_INCLUDE_DIRS}" "${CMAKE_SOURCE_DIR}/libcaf_riac") include_directories("${LIBCAF_INCLUDE_DIRS}"
"${CMAKE_CURRENT_SOURCE_DIR}/libcaf_riac")
# add libcaf_riac to the list of caf libraries # add libcaf_riac to the list of caf libraries
set(CAF_HAS_RIAC yes) set(CAF_HAS_RIAC yes)
else() else()
set(CAF_HAS_RIAC no) set(CAF_HAS_RIAC no)
endif() endif()
# build nexus if not being told otherwise # build nexus if not being told otherwise
if(NOT CAF_NO_NEXUS AND EXISTS "${CMAKE_SOURCE_DIR}/nexus/CMakeLists.txt") if(NOT CAF_NO_NEXUS
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/nexus/CMakeLists.txt")
if(NOT CAF_HAS_RIAC) if(NOT CAF_HAS_RIAC)
message(WARNING "cannot build nexus without RIAC submodule") message(WARNING "cannot build nexus without RIAC submodule")
set(CAF_NO_NEXUS yes) set(CAF_NO_NEXUS yes)
...@@ -379,7 +385,8 @@ else() ...@@ -379,7 +385,8 @@ else()
set(CAF_NO_NEXUS yes) set(CAF_NO_NEXUS yes)
endif() endif()
# build cash if not being told otherwise # build cash if not being told otherwise
if(NOT CAF_NO_CASH AND EXISTS "${CMAKE_SOURCE_DIR}/cash/CMakeLists.txt") if(NOT CAF_NO_CASH
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cash/CMakeLists.txt")
if(NOT CAF_HAS_RIAC) if(NOT CAF_HAS_RIAC)
message(WARNING "cannot build cash without RIAC submodule") message(WARNING "cannot build cash without RIAC submodule")
set(CAF_NO_CASH yes) set(CAF_NO_CASH yes)
...@@ -394,7 +401,8 @@ else() ...@@ -394,7 +401,8 @@ else()
set(CAF_NO_CASH yes) set(CAF_NO_CASH yes)
endif() endif()
# build benchmarks if not being told otherwise # build benchmarks if not being told otherwise
if(NOT CAF_NO_BENCHMARKS AND EXISTS "${CMAKE_SOURCE_DIR}/benchmarks/CMakeLists.txt") if(NOT CAF_NO_BENCHMARKS
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/CMakeLists.txt")
message(STATUS "Enter subdirectory benchmarks") message(STATUS "Enter subdirectory benchmarks")
add_subdirectory(benchmarks) add_subdirectory(benchmarks)
add_dependencies(all_benchmarks libcaf_io) add_dependencies(all_benchmarks libcaf_io)
...@@ -502,8 +510,8 @@ message(STATUS ...@@ -502,8 +510,8 @@ message(STATUS
"\nCXXFLAGS: ${ALL_CXX_FLAGS}" "\nCXXFLAGS: ${ALL_CXX_FLAGS}"
"\nLIBRARIES: ${LD_FLAGS}" "\nLIBRARIES: ${LD_FLAGS}"
"\n" "\n"
"\nSource directory: ${CMAKE_SOURCE_DIR}" "\nSource directory: ${CMAKE_CURRENT_SOURCE_DIR}"
"\nBuild directory: ${CMAKE_BINARY_DIR}" "\nBuild directory: ${CMAKE_CURRENT_BINARY_DIR}"
"\nExecutable path: ${EXECUTABLE_OUTPUT_PATH}" "\nExecutable path: ${EXECUTABLE_OUTPUT_PATH}"
"\nLibrary path: ${LIBRARY_OUTPUT_PATH}" "\nLibrary path: ${LIBRARY_OUTPUT_PATH}"
"\nInstall prefix: ${CMAKE_INSTALL_PREFIX}" "\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment