-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
67 lines (52 loc) · 1.93 KB
/
CMakeLists.txt
File metadata and controls
67 lines (52 loc) · 1.93 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
cmake_minimum_required(VERSION 3.18)
file(READ ".private/project.json" projectInfo)
#Set priority variables
string(JSON projectVersion GET "${projectInfo}" version)
string(JSON projectVersionState GET "${projectInfo}" versionState)
string(JSON projectName GET "${projectInfo}" CMakeName)
set(VERSION "${projectVersion} ${projectVersionState}")
project(${projectName}
VERSION ${projectVersion}
)
# Flags
set(programFlags "-g -fsanitize=address -Wunused -Wall -Wno-range-loop-analysis")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${programFlags}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${programFlags}")
# Warn about the current CXX compiling using for compilation
message(STATUS "CXX Compiler: ${CMAKE_CXX_COMPILER}")
message(STATUS "${projectName} version: ${projectVersion}")
# Setup
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 11) # Minimum version can be C++11 but there is some support for C++98
# Dir setup
set(srcDir "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(testDir "${CMAKE_CURRENT_SOURCE_DIR}/test")
set(incDir "${CMAKE_CURRENT_SOURCE_DIR}/inc")
# Headers from the `inc/` dir
set(headers
${incDir}/Stopwatch.hpp
${incDir}/Timer.hpp
${incDir}/Time.hpp
${incDir}/macros.hpp
${testDir}/inc/tests.hpp
)
# Sources from the `src/` dir
set(sources
${testDir}/src/main.cpp
${testDir}/src/stopwatch.cpp
${testDir}/src/timer.cpp
${testDir}/src/time.cpp
${testDir}/src/sleep.cpp
${srcDir}/Stopwatch.cpp
${srcDir}/Timer.cpp
${srcDir}/Time.cpp
${srcDir}/Sleep.cpp
)
# Create the shared library (.so)
add_library(${projectName}_shared SHARED ${sources} ${headers})
# Create the static library (.a)
add_library(${projectName}_static STATIC ${sources} ${headers})
# Link the executable
add_executable(${projectName} ${sources} ${headers})
# Optional: Link static/shared libraries to the executable
target_link_libraries(${projectName} PRIVATE ${projectName}_static)