|
1 | 1 | cmake_minimum_required(VERSION 3.16) |
2 | 2 |
|
| 3 | +# Qt is not required, this allows us to skip building the executable and only create |
| 4 | +# the single-header interface when using this as a VCPKG dependency |
| 5 | + |
| 6 | +find_package(Qt6 CONFIG COMPONENTS Core) |
| 7 | + |
| 8 | +if (Qt6_FOUND) |
| 9 | + |
| 10 | +message(STATUS "Qt6 found, building lootcli executable") |
| 11 | + |
| 12 | +find_package(tomlplusplus CONFIG REQUIRED) |
| 13 | +find_package(libloot CONFIG REQUIRED) |
| 14 | +find_package(Boost REQUIRED CONFIG COMPONENTS locale) |
| 15 | + |
| 16 | +# avoid CMake error/warning |
| 17 | +set_target_properties(libloot::loot PROPERTIES |
| 18 | + MAP_IMPORTED_CONFIG_RELEASE RelWithDebInfo |
| 19 | + MAP_IMPORTED_CONFIG_MINSIZEREL RelWithDebInfo |
| 20 | +) |
| 21 | + |
3 | 22 | add_executable(lootcli WIN32) |
| 23 | +set_target_properties(lootcli PROPERTIES |
| 24 | + CXX_STANDARD 20 |
| 25 | + WIN32_EXECUTABLE TRUE) |
| 26 | +target_sources(lootcli |
| 27 | + PRIVATE |
| 28 | + game_settings.cpp |
| 29 | + game_settings.h |
| 30 | + lootthread.cpp |
| 31 | + lootthread.h |
| 32 | + main.cpp |
| 33 | + pch.h |
| 34 | + version.h |
| 35 | + version.rc |
| 36 | + ${CMAKE_CURRENT_SOURCE_DIR}/../include/lootcli/lootcli.h |
| 37 | +) |
| 38 | +target_compile_definitions(lootcli |
| 39 | + PRIVATE |
| 40 | + _UNICODE UNICODE |
| 41 | + _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING) |
| 42 | +target_include_directories(lootcli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include) |
| 43 | +target_precompile_headers(lootcli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/pch.h) |
| 44 | +target_link_libraries(lootcli |
| 45 | + PRIVATE libloot::loot Boost::headers Boost::locale |
| 46 | + tomlplusplus::tomlplusplus Qt6::Core) |
| 47 | + |
| 48 | +if (MSVC) |
| 49 | + target_compile_options(lootcli |
| 50 | + PRIVATE |
| 51 | + "/MP" |
| 52 | + "/W4" |
| 53 | + "/external:anglebrackets" |
| 54 | + "/external:W0" |
| 55 | + ) |
| 56 | + target_link_options(lootcli |
| 57 | + PRIVATE |
| 58 | + $<$<CONFIG:RelWithDebInfo>:/LTCG /INCREMENTAL:NO /OPT:REF /OPT:ICF> |
| 59 | + ) |
| 60 | + target_compile_definitions(lootcli PRIVATE _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING) |
| 61 | + |
| 62 | + set_target_properties(lootcli PROPERTIES VS_STARTUP_PROJECT lootcli) |
| 63 | +endif() |
| 64 | + |
| 65 | +install(FILES |
| 66 | + $<TARGET_FILE:lootcli> |
| 67 | + $<TARGET_FILE:libloot::loot> |
| 68 | +DESTINATION bin/loot) |
| 69 | + |
| 70 | +endif() |
4 | 71 |
|
5 | | -mo2_configure_executable(lootcli |
6 | | - WARNINGS OFF |
7 | | - TRANSLATIONS OFF |
8 | | - PRIVATE_DEPENDS boost Qt::Core loot tomlplusplus) |
9 | | -target_include_directories(lootcli |
10 | | - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include) |
| 72 | +# library to make the header available |
| 73 | +add_library(lootcli-header INTERFACE) |
| 74 | +target_sources(lootcli-header INTERFACE |
| 75 | + FILE_SET HEADERS |
| 76 | + BASE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../include |
| 77 | + FILES ${CMAKE_CURRENT_LIST_DIR}/../include/lootcli/lootcli.h) |
| 78 | +add_library(mo2::lootcli-header ALIAS lootcli-header) |
11 | 79 |
|
12 | | -mo2_install_target(lootcli INSTALLDIR bin/loot) |
| 80 | +install(TARGETS lootcli-header EXPORT lootcliHeaderTargets FILE_SET HEADERS) |
| 81 | +install(EXPORT lootcliHeaderTargets |
| 82 | + FILE mo2-lootcli-header-targets.cmake |
| 83 | + NAMESPACE mo2:: |
| 84 | + DESTINATION lib/cmake/mo2-lootcli-header |
| 85 | +) |
0 commit comments