-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
52 lines (40 loc) · 1.42 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
cmake_minimum_required(VERSION 3.10)
project(serial)
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_BUILD_TYPE Debug)
file(GLOB_RECURSE SRC_FILES
"${CMAKE_CURRENT_LIST_DIR}/src/*.cc"
)
file (GLOB_RECURSE INC_FILES
"${CMAKE_CURRENT_LIST_DIR}/inc/*.h"
)
include_directories(
"${CMAKE_CURRENT_LIST_DIR}/inc"
)
message("${INC_FILES}")
add_library(${PROJECT_NAME}_static STATIC ${SRC_FILES} ${INC_FILES})
set_target_properties(${PROJECT_NAME}_static PROPERTIES OUTPUT_NAME "serial")
set_target_properties(${PROJECT_NAME}_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${INC_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "serial")
set_target_properties(${PROJECT_NAME} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
add_executable(${PROJECT_NAME}_test test/test.cc)
target_link_libraries(${PROJECT_NAME}_test ${PROJECT_NAME} pthread)
# out set
set (OUT_BIN ${CMAKE_BINARY_DIR}/target/lib)
set (OUT_LIB ${CMAKE_BINARY_DIR}/target/lib)
set (OUT_INC ${CMAKE_BINARY_DIR}/target/include)
set_target_properties(${PROJECT_NAME}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${OUT_LIB}"
LIBRARY_OUTPUT_DIRECTORY "${OUT_LIB}"
RUNTIME_OUTPUT_DIRECTORY "${OUT_BIN}"
)
add_custom_target(copy_files ALL
VERBATIM
COMMAND ${CMAKE_COMMAND} -E make_directory "${OUT_INC}"
COMMAND ${CMAKE_COMMAND} -E
copy_directory
"${CMAKE_CURRENT_LIST_DIR}/inc"
"${OUT_INC}"
)