| 1 |
#============================================================================= |
| 2 |
# SPDX-FileCopyrightText: 2023 Johnny Jazeix <[email protected]> |
| 3 |
# |
| 4 |
# SPDX-License-Identifier: BSD-3-Clause |
| 5 |
#============================================================================= |
| 6 |
cmake_minimum_required(VERSION 3.12) |
| 7 |
cmake_policy(SET CMP0091 NEW) |
| 8 |
|
| 9 |
project(Li_ri) |
| 10 |
|
| 11 |
# get all the redist dll needed for windows when compiling with vc |
| 12 |
set(CMAKE_INSTALL_UCRT_LIBRARIES 1) |
| 13 |
include(InstallRequiredSystemLibraries) |
| 14 |
|
| 15 |
### The current version number |
| 16 |
set(LIRI_VERSION_MAJOR 3) |
| 17 |
set(LIRI_VERSION_MINOR 1) |
| 18 |
set(LIRI_VERSION_PATCH 6) |
| 19 |
set(LIRI_VERSION ${LIRI_VERSION_MAJOR}.${LIRI_VERSION_MINOR}.${LIRI_VERSION_PATCH}) |
| 20 |
|
| 21 |
set(LIRI_EXECUTABLE_NAME Li-ri) |
| 22 |
|
| 23 |
option(USE_CONAN |
| 24 |
"Use conan to fetch dependencies" OFF) |
| 25 |
if(USE_CONAN) |
| 26 |
find_package(SDL2 REQUIRED CONFIG) |
| 27 |
find_package(SDL2_mixer REQUIRED CONFIG) |
| 28 |
else() |
| 29 |
find_package(PkgConfig REQUIRED) |
| 30 |
pkg_check_modules(SDL2 REQUIRED sdl2 SDL2_mixer) |
| 31 |
endif() |
| 32 |
|
| 33 |
set(CMAKE_CXX_STANDARD 11) |
| 34 |
set(CMAKE_CXX_EXTENSIONS OFF) |
| 35 |
|
| 36 |
|
| 37 |
option (USE_SYSTEM_SIMPLEINI "Use system SimpleIni instead of FetchContent" OFF) |
| 38 |
if(USE_SYSTEM_SIMPLEINI) |
| •39 |
pkg_check_modules(SimpleIni REQUIRED simpleini) |
| 40 |
else() |
| 41 |
include(FetchContent) |
| 42 |
FetchContent_Declare(simpleini |
| 43 |
GIT_REPOSITORY https://github.com/brofield/simpleini.git |
| 44 |
GIT_TAG 09c21bda1dc1b578fa55f4a005d79b0afd481296 # v4.22 |
| 45 |
) |
| 46 |
FetchContent_MakeAvailable(simpleini) |
| 47 |
endif() |
| 48 |
|
| 49 |
add_executable(${LIRI_EXECUTABLE_NAME} WIN32 |
| 50 |
src/audio.cc |
| 51 |
src/audio.h |
| 52 |
src/screen.cc |
| 53 |
src/screen.h |
| 54 |
src/editor.cc |
| 55 |
src/editor.h |
| 56 |
src/game.cc |
| 57 |
src/game.h |
| 58 |
src/gamepad.cc |
| 59 |
src/gamepad.h |
| 60 |
src/loco.cc |
| 61 |
src/loco.h |
| 62 |
src/main.cc |
| 63 |
src/menu.cc |
| 64 |
src/menu.h |
| 65 |
src/mouse.cc |
| 66 |
src/mouse.h |
| 67 |
src/sprite.cc |
| 68 |
src/sprite.h |
| 69 |
src/level.cc |
| 70 |
src/level.h |
| 71 |
src/utils.cc |
| 72 |
src/utils.h |
| 73 |
) |
| 74 |
|
| 75 |
configure_file(src/config.h.in "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY) |
| 76 |
target_include_directories(${LIRI_EXECUTABLE_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) |
| 77 |
|
| 78 |
if(LINUX) |
| 79 |
target_compile_definitions(${LIRI_EXECUTABLE_NAME} PUBLIC "-DSI_NO_CONVERSION=1") |
| 80 |
endif() |
| 81 |
|
| 82 |
if(USE_CONAN) |
| 83 |
target_link_libraries(${LIRI_EXECUTABLE_NAME} PRIVATE SDL2::SDL2 SDL2_mixer::SDL2_mixer) |
| 84 |
else() |
| 85 |
target_include_directories(${LIRI_EXECUTABLE_NAME} PUBLIC ${SDL2_INCLUDE_DIRS}) |
| 86 |
target_link_libraries(${LIRI_EXECUTABLE_NAME} PRIVATE ${SDL2_LINK_LIBRARIES}) |
| 87 |
endif() |
| 88 |
|
| •89 |
target_link_libraries(${LIRI_EXECUTABLE_NAME} PUBLIC simpleini) |
| 90 |
|
| 91 |
|
| 92 |
include(GNUInstallDirs) |
| 93 |
install(TARGETS ${LIRI_EXECUTABLE_NAME} |
| 94 |
ARCHIVE DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 95 |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 96 |
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 97 |
BUNDLE DESTINATION .) |
| 98 |
|
| 99 |
install(FILES io.github.petitlapin.Li-ri.appdata.xml DESTINATION "${CMAKE_INSTALL_DATADIR}/appdata/") |
| 100 |
install(FILES io.github.petitlapin.Li-ri.desktop DESTINATION "${CMAKE_INSTALL_DATADIR}/applications/") |
| 101 |
install(FILES data/Li-ri-icon-16x16.png DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/16x16/apps/" RENAME io.github.petitlapin.Li-ri.png) |
| 102 |
install(FILES data/Li-ri-icon-32x32.png DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/32x32/apps/" RENAME io.github.petitlapin.Li-ri.png) |
| 103 |
install(FILES data/Li-ri-icon-48x48.png DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps/" RENAME io.github.petitlapin.Li-ri.png) |
| 104 |
install(FILES data/Li-ri-icon-64x64.png DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/64x64/apps/" RENAME io.github.petitlapin.Li-ri.png) |
| 105 |
install(FILES data/Li-ri-icon-128x128.png DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps/" RENAME io.github.petitlapin.Li-ri.png) |
| 106 |
|
| 107 |
if(WIN32) |
| 108 |
install(DIRECTORY ${CMAKE_SOURCE_DIR}/data/ DESTINATION bin) |
| 109 |
install(DIRECTORY ${CMAKE_SOURCE_DIR}/Sounds DESTINATION bin) |
| 110 |
else() |
| 111 |
install(DIRECTORY ${CMAKE_SOURCE_DIR}/data/ DESTINATION "${CMAKE_INSTALL_DATADIR}/Li-ri") |
| 112 |
install(DIRECTORY ${CMAKE_SOURCE_DIR}/Sounds DESTINATION "${CMAKE_INSTALL_DATADIR}/Li-ri") |
| 113 |
endif() |
| 114 |
option(RILI_ENABLE_IPO |
| 115 |
"Enable interprocedural optimization (IPO/LTO) by the compiler" ON) |
| 116 |
if(RILI_ENABLE_IPO) |
| 117 |
include(CheckIPOSupported) |
| 118 |
check_ipo_supported(RESULT ipo_supported) |
| 119 |
if(ipo_supported) |
| 120 |
message("interprocedural optimization is supported by the compiler") |
| 121 |
set_property(TARGET ${LIRI_EXECUTABLE_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) |
| 122 |
else() |
| 123 |
message(WARNING |
| 124 |
"interprocedural optimization is not supported by the compiler") |
| 125 |
endif() |
| 126 |
endif() |
| 127 |
|
| 128 |
include(CPackLists.txt) |