-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
48 lines (37 loc) · 1.6 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
cmake_minimum_required(VERSION 3.14.1)
project(cmake_playground_with_current C CXX)
set (CMAKE_CXX_STANDARD 17)
find_package(Threads REQUIRED)
include(FetchContent)
Set(FETCHCONTENT_QUIET FALSE)
FetchContent_Declare(current
GIT_REPOSITORY https://github.com/c5t/current
GIT_TAG stable_2022_04_10
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE)
FetchContent_MakeAvailable(current)
include_directories(${current_SOURCE_DIR})
if(NOT WIN32)
add_custom_command(OUTPUT ${current_SOURCE_DIR}/current_build.h
WORKING_DIRECTORY ${current_SOURCE_DIR}
COMMAND scripts/gen-current-build.sh
ARGS current_build.h)
else()
add_custom_command(OUTPUT ${current_SOURCE_DIR}/current_build.h
WORKING_DIRECTORY ${current_SOURCE_DIR}
COMMAND echo
ARGS namespace current::build { constexpr static const char* kGitCommit = "Not here pls."\; } >current_build.h)
endif()
add_custom_target(current_build_h DEPENDS ${current_SOURCE_DIR}/current_build.h)
add_executable(hw0 src/hw0.cc)
target_link_libraries(hw0 PRIVATE Threads::Threads)
add_executable(hw1 src/hw1.cc)
target_link_libraries(hw1 PRIVATE Threads::Threads)
add_executable(hw2 src/hw2.cc)
target_link_libraries(hw2 PRIVATE Threads::Threads)
add_executable(hw3 src/hw3.cc)
add_dependencies(hw3 current_build_h)
target_link_libraries(hw3 PRIVATE Threads::Threads)
add_library(lib_hw4_name src/lib_hw4_name.cc)
add_executable(hw4 src/hw4.cc)
target_link_libraries(hw4 PRIVATE Threads::Threads lib_hw4_name)