-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
122 lines (90 loc) · 3.54 KB
/
CMakeLists.txt
File metadata and controls
122 lines (90 loc) · 3.54 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
cmake_minimum_required(VERSION 3.5)
# Add main.cpp file of the project root directory as a source file
project(simplelog_topic_project)
set(SOURCE_LIB_FILES src/simplelog.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.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 SHARED ${SOURCE_LIB_FILES})
if(DEFINED UNIX_LINUX)
target_compile_definitions(simplelog PUBLIC UNIX_LINUX=1)
if(DEFINED MACOSX)
target_compile_definitions(simplelog PUBLIC __MACH__=1)
endif()
set_target_properties(simplelog PROPERTIES
VERSION 1.0.8
SOVERSION 1
)
else()
target_compile_definitions(simplelog PRIVATE EXPORT_DLL_API_SIMPLE_LOG=1)
target_compile_definitions(simplelog 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 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 PUBLIC __MACH__=1)
endif()
else()
if (DEFINED MSYS2_WIN)
target_compile_definitions(simple_cpp_example PUBLIC __UNIX_LINUX_CPP11_AND_NEWERS__=1 )
else()
endif()
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.c PRIVATE cxx_std_17)
#set(CMAKE_C_COMPILER g++)
else()
if (DEFINED MSYS2_WIN)
else()
add_executable(simple_cpp_example_direct ${SOURCE_BINCPP_FILES_DIRECT})
target_compile_definitions(simple_cpp_example_direct PRIVATE __SIMPLE_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()
endif()
if(DEFINED UNIX_LINUX)
install(TARGETS simplelog LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS simple_c_example RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES include/simplelog.h DESTINATION include)
install(FILES src/simplelog.cfg DESTINATION include)
endif()
if(DEFINED MSYS2_WIN)
install(TARGETS simplelog LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS simple_c_example RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES include/simplelog.h DESTINATION include)
install(FILES src/simplelog.cfg DESTINATION include)
endif()
target_link_libraries(simple_c_example
simplelog
)
target_link_libraries(simple_cpp_example
simplelog
)
if(DEFINED UNIX_LINUX)
target_link_libraries(simplelog
pthread
)
endif()