-
Notifications
You must be signed in to change notification settings - Fork 0
/
write_cmakelists.go
85 lines (61 loc) · 1.5 KB
/
write_cmakelists.go
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main
import "os"
func writeCMakeLists(proj string, file *os.File) (err error) {
_, err = file.WriteString(`cmake_minimum_required(VERSION 3.11)
project(` + proj + `)
find_path(CATCH_INCLUDE_DIR "catch.hpp")
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
find_package(
Boost 1.67
REQUIRED
)
add_library(
` + proj + `_core
INTERFACE
)
if (MSVC)
# Win10
target_compile_definitions(` + proj + `_core INTERFACE _WIN32_WINNT=0x0A00)
endif()
target_compile_definitions(
` + proj + `_core
INTERFACE
BOOST_COROUTINES_NO_DEPRECATION_WARNING=1
BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE=1
)
target_compile_features(` + proj + `_core INTERFACE cxx_std_14)
target_include_directories(
` + proj + `_core
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(
` + proj + `_core
INTERFACE
Boost::boost
)
# keep this around, just in case
if (MSVC)
target_link_libraries(` + proj + `_core INTERFACE Boost::disable_autolinking)
endif()
add_library(test_utils INTERFACE)
target_include_directories(test_utils INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/test/include)
add_executable(
` + proj + `_tests
${CMAKE_CURRENT_SOURCE_DIR}/test/main.cpp
)
target_link_libraries(
` + proj + `_tests
PRIVATE
` + proj + `_core
test_utils
Catch
)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake.modules/")
enable_testing()
include(ParseAndAddCatchTests)
ParseAndAddCatchTests(` + proj + `_tests)
`)
return
}