-
Notifications
You must be signed in to change notification settings - Fork 30
/
CMakeLists.txt
71 lines (56 loc) · 1.74 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.0)
project(fakevim VERSION 0.0.1)
# Library name
set(bin fakevim)
# Public headers
set(${bin}_public_headers
fakevim/fakevimactions.h
fakevim/fakevimhandler.h
)
# Source files common for all platforms
set(${bin}_sources
fakevim/fakevimactions.cpp
fakevim/fakevimhandler.cpp
${${bin}_public_headers}
)
# Required pkg-config packages
set(${bin}_pkg_config_requires)
include(cmake/cxx17.cmake)
include(cmake/library.cmake)
include(cmake/qt.cmake)
include(cmake/pkg-config.cmake)
# Files with Q_OBJECT macros to pass to moc utility
set(CMAKE_INCLUDE_CURRENT_DIR ON)
qt5_wrap_cpp(${bin}_mocced "fakevim/fakevimhandler.h")
target_sources(${bin} PRIVATE ${${bin}_mocced})
target_compile_definitions(${bin} PRIVATE
QT_NO_CAST_TO_ASCII
QT_RESTRICTED_CAST_FROM_ASCII
UTILS_STATIC_LIBRARY
)
option(BUILD_TESTS "Build tests")
if (BUILD_TESTS)
message(STATUS "Building tests")
find_package(Qt5Test REQUIRED)
add_executable(fakevim_test
tests/fakevim_test.cpp
tests/fakevimplugin.h
example/editor.cpp
)
set_property(TARGET fakevim_test PROPERTY AUTOMOC ON)
target_link_libraries(fakevim_test fakevim Qt5::Widgets Qt5::Test)
target_include_directories(fakevim_test PRIVATE
${CMAKE_SOURCE_DIR}/fakevim
${CMAKE_SOURCE_DIR}
)
add_test(fakevim_test fakevim_test)
enable_testing()
endif()
option(BUILD_EXAMPLE "Build example")
if (BUILD_EXAMPLE)
message(STATUS "Building example")
add_executable(fakevim_example example/main.cpp example/editor.cpp)
set_property(TARGET fakevim_example PROPERTY AUTOMOC ON)
target_link_libraries(fakevim_example fakevim)
target_link_libraries(fakevim_example Qt5::Widgets)
endif()