-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
104 lines (75 loc) · 3.14 KB
/
CMakeLists.txt
File metadata and controls
104 lines (75 loc) · 3.14 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Add main.cpp file of the project root directory as a source file
project(simplelog-challenge-project)
set(SOURCE_LIB_FILES src/simplelog-challenge.c )
set(SOURCE_BIN_FILES tests/c_test/main.c)
set(SOURCE_BINCPP_FILES tests/cpp_test/main.cpp)
set(SOURCE_BINCPP_FILES_DIRECT tests/cpp_test/main.cpp src/simplelog-challenge.c)
# Add executable target with source files listed in SOURCE_FILES variable
#add_compile_definitions(EXPORT_DLL_API_SIMPLE_LOG simplelog)
#add_compile_definitions(_CRT_SECURE_NO_WARNINGS simplelog)
include_directories(./include)
add_library(simplelog-challenge SHARED ${SOURCE_LIB_FILES})
if(DEFINED UNIX_LINUX)
target_compile_definitions(simplelog-challenge PUBLIC UNIX_LINUX=1)
if(DEFINED MACOSX)
target_compile_definitions(simplelog-challenge PUBLIC __MACH__=1)
endif()
set_target_properties(simplelog-challenge PROPERTIES
VERSION 1.0.5
SOVERSION 1
)
else()
target_compile_definitions(simplelog-challenge PRIVATE EXPORT_DLL_API_SPC_LOG=1)
target_compile_definitions(simplelog-challenge PUBLIC _CRT_SECURE_NO_WARNINGS=1)
endif()
include_directories(./include)
add_executable(simple_c_example ${SOURCE_BIN_FILES})
if(DEFINED UNIX_LINUX)
target_compile_definitions(simple_c_example PUBLIC UNIX_LINUX=1)
if(DEFINED MACOSX)
target_compile_definitions(simplelog-challenge PUBLIC __MACH__=1)
endif()
else()
target_compile_definitions(simple_c_example PUBLIC _CRT_SECURE_NO_WARNINGS=1)
endif()
include_directories(./include)
add_executable(simple_cpp_example ${SOURCE_BINCPP_FILES})
target_compile_definitions(simple_cpp_example PUBLIC _CRT_SECURE_NO_WARNINGS=1)
if(DEFINED UNIX_LINUX)
target_compile_definitions(simple_cpp_example PUBLIC __UNIX_LINUX_CPP11_AND_NEWERS__=1 UNIX_LINUX=1)
target_compile_definitions(simple_cpp_example PUBLIC UNIX_LINUX=1)
if(DEFINED MACOSX)
target_compile_definitions(simplelog-challenge PUBLIC __MACH__=1)
endif()
else()
target_compile_definitions(simple_cpp_example PUBLIC _HAS_STD_BYTE=0)
endif()
include_directories(./include)
if(DEFINED UNIX_LINUX)
#add_executable(simple_cpp_example_direct ${SOURCE_BINCPP_FILES_DIRECT})
#target_compile_definitions(simple_cpp_example_direct PUBLIC UNIX_LINUX=1)
#target_compile_definitions(simple_cpp_example_direct PUBLIC __UNIX_LINUX_CPP11_AND_NEWERS__=1 )
#target_compile_features(simplelog-challenge-challenge.c PRIVATE cxx_std_17)
#set(CMAKE_C_COMPILER g++)
else()
add_executable(simple_cpp_example_direct ${SOURCE_BINCPP_FILES_DIRECT})
target_compile_definitions(simple_cpp_example_direct PRIVATE __SPC_STATIC_LOG__=1)
target_compile_definitions(simple_cpp_example_direct PUBLIC _CRT_SECURE_NO_WARNINGS=1)
target_compile_definitions(simple_cpp_example_direct PUBLIC _HAS_STD_BYTE=0)
endif()
if(DEFINED UNIX_LINUX)
install(TARGETS simplelog-challenge LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES include/simplelog-challenge.h DESTINATION include)
install(FILES src/simplelog-challenge.cfg DESTINATION include)
endif()
target_link_libraries(simple_c_example
simplelog-challenge
)
target_link_libraries(simple_cpp_example
simplelog-challenge
)
if(DEFINED UNIX_LINUX)
target_link_libraries(simplelog-challenge
pthread
)
endif()