|
| 1 | +cmake_minimum_required(VERSION 3.0) |
| 2 | +project(fakevim VERSION 0.0.1) |
| 3 | + |
| 4 | +# Library name |
| 5 | +set(bin fakevim) |
| 6 | + |
| 7 | +# Public headers |
| 8 | +set(${bin}_public_headers |
| 9 | + fakevim/fakevimactions.h |
| 10 | + fakevim/fakevimhandler.h |
| 11 | + ) |
| 12 | + |
| 13 | +# Source files common for all platforms |
| 14 | +set(${bin}_sources |
| 15 | + fakevim/fakevimactions.cpp |
| 16 | + fakevim/fakevimhandler.cpp |
| 17 | + fakevim/utils/hostosinfo.cpp |
| 18 | + fakevim/utils/osspecificaspects.h |
| 19 | + fakevim/utils/qtcassert.cpp |
| 20 | + ${${bin}_public_headers} |
| 21 | + ) |
| 22 | + |
| 23 | +# Required pkg-config packages |
| 24 | +set(${bin}_pkg_config_requires) |
| 25 | + |
| 26 | +include(cmake/cxx17.cmake) |
| 27 | +include(cmake/library.cmake) |
| 28 | +include(cmake/qt.cmake) |
| 29 | +include(cmake/pkg-config.cmake) |
| 30 | + |
| 31 | +# Files with Q_OBJECT macros to pass to moc utility |
| 32 | +set(CMAKE_INCLUDE_CURRENT_DIR ON) |
| 33 | +qt5_wrap_cpp(${bin}_mocced "fakevim/fakevimhandler.h") |
| 34 | +target_sources(${bin} PRIVATE ${${bin}_mocced}) |
| 35 | + |
| 36 | +target_compile_definitions(${bin} PRIVATE |
| 37 | + QT_NO_CAST_TO_ASCII |
| 38 | + QT_RESTRICTED_CAST_FROM_ASCII |
| 39 | + QTCREATOR_UTILS_STATIC_LIB |
| 40 | +) |
| 41 | + |
| 42 | +option(BUILD_TESTS "Build tests") |
| 43 | +if (BUILD_TESTS) |
| 44 | + message(STATUS "Building tests") |
| 45 | + |
| 46 | + find_package(Qt5Test REQUIRED) |
| 47 | + |
| 48 | + add_executable(fakevim_test |
| 49 | + tests/fakevim_test.cpp |
| 50 | + tests/fakevimplugin.h |
| 51 | + example/editor.cpp |
| 52 | + ) |
| 53 | + set_property(TARGET fakevim_test PROPERTY AUTOMOC ON) |
| 54 | + target_link_libraries(fakevim_test fakevim Qt5::Widgets Qt5::Test) |
| 55 | + |
| 56 | + target_include_directories(fakevim_test PRIVATE |
| 57 | + ${CMAKE_SOURCE_DIR}/fakevim |
| 58 | + ${CMAKE_SOURCE_DIR} |
| 59 | + ) |
| 60 | + |
| 61 | + add_test(fakevim_test fakevim_test) |
| 62 | + enable_testing() |
| 63 | +endif() |
| 64 | + |
| 65 | +option(BUILD_EXAMPLE "Build example") |
| 66 | +if (BUILD_EXAMPLE) |
| 67 | + message(STATUS "Building example") |
| 68 | + |
| 69 | + add_executable(fakevim_example example/main.cpp example/editor.cpp) |
| 70 | + set_property(TARGET fakevim_example PROPERTY AUTOMOC ON) |
| 71 | + |
| 72 | + target_link_libraries(fakevim_example fakevim) |
| 73 | + target_link_libraries(fakevim_example Qt5::Widgets) |
| 74 | +endif() |
0 commit comments