diff --git a/CMakeLists.txt b/CMakeLists.txt index 85d2f64ce..6583f7cd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ list(APPEND CMAKE_MODULE_PATH ${ETH_CMAKE_DIR}) # Set the build type, if none was specified. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - if(EXISTS "${CMAKE_SOURCE_DIR}/.git") + if(EXISTS "${PROJECT_SOURCE_DIR}/.git") set(DEFAULT_BUILD_TYPE "RelWithDebInfo") else() set(DEFAULT_BUILD_TYPE "Release") @@ -66,12 +66,12 @@ include(EthUtils) # Create license.h from LICENSE.txt and template # Converting to char array is required due to MSVC's string size limit. -file(READ ${CMAKE_SOURCE_DIR}/LICENSE.txt LICENSE_TEXT HEX) +file(READ ${PROJECT_SOURCE_DIR}/LICENSE.txt LICENSE_TEXT HEX) string(REGEX MATCHALL ".." LICENSE_TEXT "${LICENSE_TEXT}") string(REGEX REPLACE ";" ",\n\t0x" LICENSE_TEXT "${LICENSE_TEXT}") set(LICENSE_TEXT "0x${LICENSE_TEXT}") -configure_file("${CMAKE_SOURCE_DIR}/cmake/templates/license.h.in" include/license.h) +configure_file("${PROJECT_SOURCE_DIR}/cmake/templates/license.h.in" include/license.h) include(EthOptions) configure_project(TESTS) diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 4dd593458..6cfa864c1 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -28,7 +28,7 @@ if(PEDANTIC) endif() # Prevent the path of the source directory from ending up in the binary via __FILE__ macros. -eth_add_cxx_compiler_flag_if_supported("-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=/solidity") +eth_add_cxx_compiler_flag_if_supported("-fmacro-prefix-map=${PROJECT_SOURCE_DIR}=/solidity") # -Wpessimizing-move warns when a call to std::move would prevent copy elision # if the argument was not wrapped in a call. This happens when moving a local diff --git a/cmake/fmtlib.cmake b/cmake/fmtlib.cmake index 5ed196cea..792bf3b02 100644 --- a/cmake/fmtlib.cmake +++ b/cmake/fmtlib.cmake @@ -2,8 +2,8 @@ include(FetchContent) FetchContent_Declare( fmtlib - PREFIX "${CMAKE_BINARY_DIR}/deps" - DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads" + PREFIX "${PROJECT_BINARY_DIR}/deps" + DOWNLOAD_DIR "${PROJECT_SOURCE_DIR}/deps/downloads" DOWNLOAD_NAME fmt-8.0.1.tar.gz URL https://github.com/fmtlib/fmt/archive/8.0.1.tar.gz URL_HASH SHA256=b06ca3130158c625848f3fb7418f235155a4d389b2abc3a6245fb01cb0eb1e01 diff --git a/cmake/jsoncpp.cmake b/cmake/jsoncpp.cmake index 29b8f5f05..cf1cc656b 100644 --- a/cmake/jsoncpp.cmake +++ b/cmake/jsoncpp.cmake @@ -6,7 +6,7 @@ else() set(JSONCPP_CMAKE_COMMAND ${CMAKE_COMMAND}) endif() -set(prefix "${CMAKE_BINARY_DIR}/deps") +set(prefix "${PROJECT_BINARY_DIR}/deps") set(JSONCPP_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}") set(JSONCPP_INCLUDE_DIR "${prefix}/include") @@ -42,7 +42,7 @@ endif() ExternalProject_Add(jsoncpp-project PREFIX "${prefix}" - DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads" + DOWNLOAD_DIR "${PROJECT_SOURCE_DIR}/deps/downloads" DOWNLOAD_NAME jsoncpp-1.9.3.tar.gz URL https://github.com/open-source-parsers/jsoncpp/archive/1.9.3.tar.gz URL_HASH SHA256=8593c1d69e703563d94d8c12244e2e18893eeb9a8a9f8aa3d09a327aa45c8f7d diff --git a/cmake/range-v3.cmake b/cmake/range-v3.cmake index 75ed5a92e..d2f54452b 100644 --- a/cmake/range-v3.cmake +++ b/cmake/range-v3.cmake @@ -6,12 +6,12 @@ else() set(RANGE_V3_CMAKE_COMMAND ${CMAKE_COMMAND}) endif() -set(prefix "${CMAKE_BINARY_DIR}/deps") +set(prefix "${PROJECT_BINARY_DIR}/deps") set(RANGE_V3_INCLUDE_DIR "${prefix}/include") ExternalProject_Add(range-v3-project PREFIX "${prefix}" - DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads" + DOWNLOAD_DIR "${PROJECT_SOURCE_DIR}/deps/downloads" DOWNLOAD_NAME range-v3-0.12.0.tar.gz URL https://github.com/ericniebler/range-v3/archive/0.12.0.tar.gz URL_HASH SHA256=015adb2300a98edfceaf0725beec3337f542af4915cec4d0b89fa0886f4ba9cb diff --git a/libsolutil/CMakeLists.txt b/libsolutil/CMakeLists.txt index b368e12f9..201429bb7 100644 --- a/libsolutil/CMakeLists.txt +++ b/libsolutil/CMakeLists.txt @@ -46,7 +46,7 @@ set(sources add_library(solutil ${sources}) target_link_libraries(solutil PUBLIC jsoncpp Boost::boost Boost::filesystem Boost::system range-v3 fmt::fmt-header-only) -target_include_directories(solutil PUBLIC "${CMAKE_SOURCE_DIR}") +target_include_directories(solutil PUBLIC "${PROJECT_SOURCE_DIR}") add_dependencies(solutil solidity_BuildInfo.h) if(SOLC_LINK_STATIC) diff --git a/libstdlib/CMakeLists.txt b/libstdlib/CMakeLists.txt index a4523b99e..65a3a1cda 100644 --- a/libstdlib/CMakeLists.txt +++ b/libstdlib/CMakeLists.txt @@ -1,18 +1,18 @@ # This will re-generate the headers if any file within src was modified. -set_directory_properties(PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/stdlib/src/) +set_directory_properties(PROPERTY CMAKE_CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/stdlib/src/) set(STDLIB stub) set(GENERATED_STDLIB_HEADERS) foreach(src IN LISTS STDLIB) - set(STDLIB_FILE ${CMAKE_SOURCE_DIR}/libstdlib/src/${src}.sol) + set(STDLIB_FILE ${PROJECT_SOURCE_DIR}/libstdlib/src/${src}.sol) file(READ ${STDLIB_FILE} STDLIB_FILE_CONTENT HEX) string(REGEX MATCHALL ".." STDLIB_FILE_CONTENT "${STDLIB_FILE_CONTENT}") list(REMOVE_ITEM STDLIB_FILE_CONTENT "0d") string(REGEX REPLACE ";" ",\n\t0x" STDLIB_FILE_CONTENT "${STDLIB_FILE_CONTENT}") set(STDLIB_FILE_CONTENT "0x${STDLIB_FILE_CONTENT}") set(STDLIB_FILE_NAME ${src}) - configure_file("${CMAKE_SOURCE_DIR}/libstdlib/stdlib.src.h.in" ${CMAKE_BINARY_DIR}/include/libstdlib/${src}.h NEWLINE_STYLE LF @ONLY) - list(APPEND GENERATED_STDLIB_HEADERS ${CMAKE_BINARY_DIR}/include/libstdlib/${src}.h) + configure_file("${PROJECT_SOURCE_DIR}/libstdlib/stdlib.src.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/${src}.h NEWLINE_STYLE LF @ONLY) + list(APPEND GENERATED_STDLIB_HEADERS ${PROJECT_BINARY_DIR}/include/libstdlib/${src}.h) endforeach() -configure_file("${CMAKE_SOURCE_DIR}/libstdlib/stdlib.h.in" ${CMAKE_BINARY_DIR}/include/libstdlib/stdlib.h NEWLINE_STYLE LF @ONLY) +configure_file("${PROJECT_SOURCE_DIR}/libstdlib/stdlib.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/stdlib.h NEWLINE_STYLE LF @ONLY)