-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
95 lines (72 loc) · 3.23 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# =============================================================================
# 2018 by KjellKod This is PUBLIC DOMAIN to use at your own risk and comes
# with no warranties. This code is yours to share, use and modify with no
# strings attached and no restrictions or obligations.
#
# For more information see g3log/LICENSE or refer refer to http://unlicense.org
# ==============================================================================
cmake_minimum_required (VERSION 3.5)
enable_language(CXX)
PROJECT (Q)
set(MAJOR_VERSION 1)
if ( NOT VERSION )
execute_process(COMMAND bash "-c" "git rev-list --branches HEAD | wc -l | tr -d ' ' | tr -d '\n'" OUTPUT_VARIABLE GIT_VERSION WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
message( STATUS "Compiler: ${CMAKE_C_COMPILER}")
message(STATUS "C++ version: ${CMAKE_CXX_STANDARD}")
set(MINOR_VERSION 1)
math(EXPR VERSION-BASE ${GIT_VERSION}/255)
math(EXPR VERSION-REMAINDER ${GIT_VERSION}%255)
message( STATUS "git build version: ${GIT_VERSION}" )
message( STATUS "version base: ${VERSION-BASE}" )
message( STATUS "version remainder: ${VERSION-REMAINDER}" )
set(BUILD_NUMBER ${VERSION-BASE})
set(VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_NUMBER}-${VERSION-REMAINDER})
message( STATUS "Software Version: ${VERSION}" )
SET(PROJECT_SRC ${Q_SOURCE_DIR}/src)
SET(DIR_UNIT_TEST ${Q_SOURCE_DIR}/test)
SET(DIR_3RDPARTY ${Q_SOURCE_DIR}/3rdparty)
message("source directory: ${PROJECT_SRC}")
include_directories(${SRC})
# Set with "cmake -DSYSTEM_INCLUDE=...."
if(SYSTEM_INCLUDE)
include_directories(${SYSTEM_INCLUDE})
endif()
# change to c++20 in version 2.0
if (MSVC)
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wunused -pthread -D_GLIBCXX_USE_NANOSLEEP")
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options("-stdlib=libc++")
#add_compile_options("-std=c++20")
endif()
file(GLOB SRC_FILES ${PROJECT_SRC}/g3log/*.h ${PROJECT_SRC}/q/*.hpp ${PROJECT_SRC}/*.cpp)
file(GLOB HEADER_FILES ${PROJECT_SRC}/q/*.hpp)
message("source files: ${SRC_FILES}")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type (default: Release)" FORCE)
endif()
# Set compiler flags for high performance
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
endif()
set(Q_LIBRARY qlib)
add_library(${Q_LIBRARY} SHARED ${SRC_FILES})
set(${Q_LIBRARY}_VERSION_STRING ${VERSION})
message( STATUS "Creating ${Q_LIBRARY} VERSION: ${VERSION}" )
set_target_properties(${Q_LIBRARY} PROPERTIES LINKER_LANGUAGE CXX SOVERSION ${VERSION})
# ==========================================================================
# UNIT TEST OPTIONS:
# ============================================================================
INCLUDE (${Q_SOURCE_DIR}/test/test.cmake)
# ==========================================================================
# EXAMPLES
# ============================================================================
INCLUDE (${Q_SOURCE_DIR}/examples/examples.cmake)
# ==========================================================================
# Benchmark
# ============================================================================
INCLUDE (${Q_SOURCE_DIR}/benchmark/benchmark.cmake)