-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
71 lines (59 loc) · 2.32 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
cmake_minimum_required (VERSION 3.10.0)
project (High_Performance_Timing_Library)
# The version number.
execute_process(
COMMAND git describe --always --tags
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE hptl_VERSION)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
add_definitions(-std=gnu11 -Wall -Wextra -Werror -O3 -g -pipe -flto -ffat-lto-objects)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto -O3 -g -pipe")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto -O3 -g -pipe")
#Import all .hpp
file(GLOB lib_INCLUDE
"include/*.h"
"include/*.hpp"
)
#Import all .cpp
file(GLOB lib_SRC
"src/*.c"
"src/*.cpp"
)
include(Config.cmake)
#The library
# this is the "object library" target: compiles the sources only once
add_library(hptl_obj OBJECT ${lib_SRC} ${lib_INCLUDE})
# shared libraries need PIC
set_property(TARGET ${hptl_obj} PROPERTY POSITION_INDEPENDENT_CODE 1)
# actual shared and static libraries built from the same object files
add_library(hptl-shared SHARED $<TARGET_OBJECTS:hptl_obj>)
add_library(hptl STATIC $<TARGET_OBJECTS:hptl_obj>)
target_include_directories(hptl_obj PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(hptl-shared PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(hptl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
# Rename the lib
set_target_properties(hptl PROPERTIES
OUTPUT_NAME hptl
ARCHIVE_OUTPUT_NAME hptl)
set_target_properties(hptl-shared PROPERTIES
OUTPUT_NAME hptl
ARCHIVE_OUTPUT_NAME hptl)
#Library Dependencies
if(HPTL_CLOCKREALTIME)
target_link_libraries(hptl-shared rt)
target_link_libraries(hptl rt)
endif()
#Tests
add_executable(deviationTest src/test/deviationTest.c)
add_executable(pdeviationTest src/test/pdeviationTest.c)
add_executable(integrityTest src/test/integrityTest.c)
add_executable(exampleTest src/test/exampleTest.c)
add_executable(performanceTest src/test/performanceTest.c)
#Link library executables
target_link_libraries(deviationTest hptl)
target_link_libraries(pdeviationTest hptl)
target_link_libraries(integrityTest hptl)
target_link_libraries(exampleTest hptl)
target_link_libraries(performanceTest hptl)