-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
83 lines (60 loc) · 2.04 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
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
cmake_minimum_required(VERSION 3.6)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Release/Debug")
endif()
project(ubuild VERSION 0.3.0 LANGUAGES CXX C)
message(STATUS "yay = $ENV{YAY}")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++17")
endif()
set(TEAPORT_SRC_DIR "${PROJECT_SOURCE_DIR}/teas")
function(add_tea name)
if("${name}" STREQUAL "")
message(FATAL_ERROR "add_tea requires name argument to be not empty")
endif()
set(dir ${CMAKE_CURRENT_LIST_DIR}/teas/${name})
if(NOT EXISTS ${dir})
message(FATAL_ERROR "dir not existS: ${dir}")
endif()
file(GLOB_RECURSE cpp ${dir}/*.cpp ${dir}/*.c)
file(GLOB_RECURSE hpp ${dir}/*.hpp ${dir}/*.h)
if("${cpp}" STREQUAL "")
message(STATUS "interface library ${name}")
add_library(${name} INTERFACE)
target_include_directories(${name} INTERFACE ${dir})
else()
message(STATUS "static library ${name}")
add_library(${name} STATIC ${cpp} ${hpp})
target_include_directories(${name} PUBLIC ${dir})
endif()
list(APPEND TEA_LIBS ${name})
set(TEA_LIBS ${TEA_LIBS} PARENT_SCOPE)
endfunction()
add_tea(iostream)
add_tea(sqlite)
add_library(sqlite3 ALIAS sqlite)
add_subdirectory(teas/teaport_utils teaport_utils)
add_subdirectory(teas/subprocess subprocess)
file(GLOB_RECURSE src_files src/cpp/*.cpp)
add_executable(buildhl ${src_files})
target_include_directories(buildhl PUBLIC
src/cpp
${CMAKE_CURRENT_BINARY_DIR}/include
)
if(MSVC)
target_compile_options(buildhl PUBLIC -Zc:__cplusplus)
endif()
target_link_libraries(buildhl PUBLIC
teaport_utils subprocess iostream
)
target_compile_definitions(buildhl PRIVATE
PROJECT_VERSION="${PROJECT_VERSION}")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_link_libraries(buildhl PUBLIC stdc++fs)
if(NOT WIN32)
target_link_libraries(buildhl PUBLIC pthread dl)
endif()
endif()
install(TARGETS buildhl DESTINATION bin)