-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
69 lines (55 loc) · 2.11 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
cmake_minimum_required(VERSION 3.12)
project(LemmaGen VERSION 1.3.2
DESCRIPTION "LemmaGen lemmatizer"
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
# ========================
# SHARED LIBRARY
# ========================
file(GLOB lemmagen_src_files ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
set(LINUX_LINKER_FLAGS "-Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,--gc-sections")
set(MACOS_LINKER_FLAGS "-Wl,-dead_strip")
if (UNIX)
set(WARNINGS -Wall -Wno-c++98-compat -Wno-old-style-cast -Wno-c++98-compat-pedantic -Wno-cast-align -Wno-padded)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(WARNINGS -Weverything ${WARNINGS})
endif()
endif(UNIX)
add_library(lemmagen SHARED ${lemmagen_src_files})
target_compile_options(lemmagen PUBLIC ${WARNINGS} -ffunction-sections -fdata-sections -fstack-protector -fvisibility-inlines-hidden -static)
target_compile_definitions(lemmagen PRIVATE _FORTIFY_SOURCE=2)
target_include_directories(lemmagen INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
set_target_properties(lemmagen PROPERTIES
CXX_VISIBILITY_PRESET hidden)
# Set OS specific compile flags
if (APPLE)
set_target_properties(lemmagen PROPERTIES LINK_FLAGS ${MACOS_LINKER_FLAGS})
endif(APPLE)
# ========================
# BINARY
# ========================
#add_executable(lemmagen_bin src/main.c)
#target_link_libraries(lemmagen_bin lemmagen)
# ========================
# TESTS
# ========================
include(FetchContent)
include(GoogleTest)
if (WIN32)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif(WIN32)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.8.1
)
FetchContent_GetProperties(googletest)
if(NOT googletest_POPULATED)
FetchContent_Populate(googletest)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
endif()
enable_testing()
file(GLOB lemmagen_test_files ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp)
add_executable(lemmagen_tests ${lemmagen_test_files})
target_link_libraries(lemmagen_tests lemmagen gtest gtest_main)
gtest_add_tests(TARGET lemmagen_tests AUTO)