Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and download 3rd-party to build dir #63

Merged
merged 3 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,5 @@ msvc/2015/TestTsLib/TestTsLib/settings.json
# CPack
CPackConfig.cmake

# Cached 3rd-party
3rd-party/googletest*
3rd-party/benchmark*

# Windows CPack
_CPack_Packages
_CPack_Packages
24 changes: 12 additions & 12 deletions 3rd-party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ include(ExternalProject)
ExternalProject_Add(
plog
URL ${CMAKE_CURRENT_SOURCE_DIR}/plog-${PLOG_VERSION}.tar.gz
INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/plog-${PLOG_VERSION}
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/plog-${PLOG_VERSION}
CMAKE_ARGS -D CMAKE_BUILD_TYPE=Release
-D CMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-D PLOG_BUILD_SAMPLES=OFF
Expand All @@ -50,7 +50,7 @@ ExternalProject_Add(
ExternalProject_Add(
json
URL ${CMAKE_CURRENT_SOURCE_DIR}/json-${NLOHMANN_VERSION}.tar.gz
INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/json-${NLOHMANN_VERSION}
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/json-${NLOHMANN_VERSION}
CMAKE_ARGS -D CMAKE_BUILD_TYPE=Release
-D BUILD_TESTING=OFF
-D CMAKE_INSTALL_PREFIX=<INSTALL_DIR>
Expand All @@ -70,17 +70,17 @@ if(NOT USE_DOCKER AND NOT ENABLE_WEBASSEMBLY AND ENABLE_TESTS)
endif(APPLE)

# Download and unpack googletest at configure time
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists_googletest.txt.in ${CMAKE_CURRENT_SOURCE_DIR}/googletest-download/CMakeLists.txt)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists_googletest.txt.in ${CMAKE_CURRENT_BINARY_DIR}/googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/googletest-download
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download
)
if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/googletest-download )
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()
Expand All @@ -91,8 +91,8 @@ if(NOT USE_DOCKER AND NOT ENABLE_WEBASSEMBLY AND ENABLE_TESTS)

# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/googletest-src
${CMAKE_CURRENT_SOURCE_DIR}/googletest-build
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)

# The gtest/gtest_main targets carry header search path
Expand All @@ -118,16 +118,16 @@ if(NOT USE_DOCKER AND NOT ENABLE_WEBASSEMBLY AND ENABLE_TESTS)
set(BENCHMARK_ENABLE_TESTING OFF)

# Download and unpack benchmark at configure time
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists_benchmark.txt.in ${CMAKE_CURRENT_SOURCE_DIR}/benchmark-download/CMakeLists.txt)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists_benchmark.txt.in ${CMAKE_CURRENT_BINARY_DIR}/benchmark-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/benchmark-download )
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/benchmark-download )
if(result)
message(FATAL_ERROR "CMake step for benchmark failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/benchmark-download )
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/benchmark-download )
if(result)
message(FATAL_ERROR "Build step for benchmark failed: ${result}")
endif()
Expand All @@ -139,8 +139,8 @@ if(NOT USE_DOCKER AND NOT ENABLE_WEBASSEMBLY AND ENABLE_TESTS)

# Add benchmark directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/benchmark-src
${CMAKE_CURRENT_SOURCE_DIR}/benchmark-build
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/benchmark-src
${CMAKE_CURRENT_BINARY_DIR}/benchmark-build
EXCLUDE_FROM_ALL)

# The gtest/gtest_main targets carry header search path
Expand Down
4 changes: 2 additions & 2 deletions 3rd-party/CMakeLists_benchmark.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ include(ExternalProject)
ExternalProject_Add(benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG main
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/benchmark-src"
BINARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/benchmark-build"
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/benchmark-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/benchmark-build"
GIT_SHALLOW 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
Expand Down
4 changes: 2 additions & 2 deletions 3rd-party/CMakeLists_googletest.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main
GIT_SHALLOW 1
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/googletest-src"
BINARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/googletest-build"
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ endif()


#-------------------
# 3rd-party
# Include 3rd-party
#-------------------
include_directories(3rd-party/json-${NLOHMANN_VERSION}/include)
include_directories(3rd-party/plog-${PLOG_VERSION}/include)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/3rd-party/json-${NLOHMANN_VERSION}/include)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/3rd-party/plog-${PLOG_VERSION}/include)


#-------------------
Expand Down