solidity/cmake/range-v3.cmake
Jun Zhang 8c5ecd1c01
Fix incorrectly CMAKE_BINARY_DIR usage
Similiar to CMAKE_SOURCE_DIR. Using CMAKE_BINARY_DIR will put the
generated header (stdlib.h) in build/include/solidity/libstdlib but it
should start with build/third-party/solidity or the library can't find
the header.

Signed-off-by: Jun Zhang <jun@junz.org>
2023-06-10 00:35:24 +08:00

39 lines
1.5 KiB
CMake

include(ExternalProject)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
set(RANGE_V3_CMAKE_COMMAND emcmake cmake)
else()
set(RANGE_V3_CMAKE_COMMAND ${CMAKE_COMMAND})
endif()
set(prefix "${PROJECT_BINARY_DIR}/deps")
set(RANGE_V3_INCLUDE_DIR "${prefix}/include")
ExternalProject_Add(range-v3-project
PREFIX "${prefix}"
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
CMAKE_COMMAND ${RANGE_V3_CMAKE_COMMAND}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DBUILD_TESTING=OFF
-DRANGES_CXX_STD=${CMAKE_CXX_STANDARD}
-DRANGE_V3_DOCS=OFF
-DRANGE_V3_EXAMPLES=OFF
-DRANGE_V3_TESTS=OFF
-DRANGES_BUILD_CALENDAR_EXAMPLE=OFF
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
BUILD_BYPRODUCTS "${RANGE_V3_INCLUDE_DIR}/range/v3/all.hpp"
)
# Create range-v3 imported library
add_library(range-v3 INTERFACE IMPORTED)
file(MAKE_DIRECTORY ${RANGE_V3_INCLUDE_DIR}) # Must exist.
set_target_properties(range-v3 PROPERTIES
INTERFACE_COMPILE_OPTIONS "\$<\$<CXX_COMPILER_ID:MSVC>:/permissive->"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${RANGE_V3_INCLUDE_DIR}
INTERFACE_INCLUDE_DIRECTORIES ${RANGE_V3_INCLUDE_DIR})
add_dependencies(range-v3 range-v3-project)