git repos / blockattack-game

blame: CMakeLists.txt

normal view · raw

e157f0f3 Poul Sander 2024-05-09 16:44 1
cmake_minimum_required(VERSION 3.5.1...3.27.4)
e566d265 sago007 2016-01-16 14:19 2
project (blockattack)
e566d265 sago007 2016-01-16 14:19 3
set(BIN_DIR ${blockattack_SOURCE_DIR}/Game)
e566d265 sago007 2016-01-16 14:19 4
289b307c Poul Sander 2022-02-18 20:14 5
SET(CPACK_PACKAGE_VERSION "2.9.0-SNAPSHOT")
b1a99ae7 Poul Sander 2016-05-27 21:08 6
SET(CPACK_PACKAGE_VERSION_MAJOR "2")
289b307c Poul Sander 2022-02-18 20:14 7
SET(CPACK_PACKAGE_VERSION_MINOR "9")
b1a99ae7 Poul Sander 2016-05-27 21:08 8
SET(CPACK_PACKAGE_VERSION_PATCH "0")
b1a99ae7 Poul Sander 2016-05-27 21:08 9
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Block Attack - Rise of the Blocks ${CPACK_PACKAGE_VERSION}")
b1a99ae7 Poul Sander 2016-05-27 21:08 10
SET(CPACK_PACKAGE_VENDOR "Poul Sander")
b1a99ae7 Poul Sander 2016-05-27 21:08 11
INCLUDE(CPack)
b1a99ae7 Poul Sander 2016-05-27 21:08 12
5614ab55 sago007 2016-01-17 13:44 13
# Define install paths
b1a99ae7 Poul Sander 2016-05-27 21:08 14
set(INSTALL_BIN_DIR "bin" CACHE STRING "Install executable in this directory")
b1a99ae7 Poul Sander 2016-05-27 21:08 15
set(INSTALL_DATA_DIR "share/blockattack" CACHE STRING "Install data to this directory")
b240dbfa Michael Straube 2017-01-09 18:25 16
set(INSTALL_MAN_DIR "share/man/man6" CACHE STRING "Install the man page to this directory")
b240dbfa Michael Straube 2017-01-09 18:25 17
set(INSTALL_APPLICATIONS_DIR "share/applications" CACHE STRING "Install the .desktop file to this directory")
b240dbfa Michael Straube 2017-01-09 18:25 18
set(INSTALL_ICONS_DIR "share/icons/hicolor" CACHE STRING "Install the icon in a subfolder in this directory")
9779d6e3 sago007 2016-04-30 11:35 19
set(INSTALL_LOCALE_DIR "${INSTALL_DATA_DIR}/locale/" CACHE STRING "Install translation to this dir")
28735382 sago007 2019-04-28 11:01 20
set(INSTALL_METAINFO_DIR "share/metainfo" CACHE STRING "Install appstream matedata to this directory")
2c2c318c sago007 2016-01-17 15:17 21
f8deb5b9 Poul Sander 2022-01-15 13:55 22
option(BLOCKATTACK_USE_EMBEDDED_FMT "Use the embedded version of {fmt}" ON)
c74066db Poul Sander 2022-02-16 12:14 23
option(BLOCKATTACK_USE_EMBEDDED_PLATFORM_FOLDERS "Use the embedded version of PlatformFolders" ON)
f8deb5b9 Poul Sander 2022-01-15 13:55 24
daad7b02 sago007 2016-01-19 19:33 25
# This sets up the exe icon for windows under mingw.
daad7b02 sago007 2016-01-19 19:33 26
# Taken from https://hansonry.wordpress.com/2010/12/15/windows-application-icon-using-mingw-and-cmake/
daad7b02 sago007 2016-01-19 19:33 27
set(RES_FILES "")
daad7b02 sago007 2016-01-19 19:33 28
if(MINGW)
daad7b02 sago007 2016-01-19 19:33 29
 set(RES_FILES "${blockattack_SOURCE_DIR}/source/code/winicon.rc")
daad7b02 sago007 2016-01-19 19:33 30
 set(CMAKE_RC_COMPILER_INIT windres)
daad7b02 sago007 2016-01-19 19:33 31
 ENABLE_LANGUAGE(RC)
daad7b02 sago007 2016-01-19 19:33 32
 SET(CMAKE_RC_COMPILE_OBJECT
daad7b02 sago007 2016-01-19 19:33 33
 "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
daad7b02 sago007 2016-01-19 19:33 34
endif(MINGW)
daad7b02 sago007 2016-01-19 19:33 35
daad7b02 sago007 2016-01-19 19:33 36
if (WIN32)
6b427a55 Poul Sander 2019-02-13 17:49 37
      SET(GUI_TYPE WIN32)
6b427a55 Poul Sander 2019-02-13 17:49 38
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686")
6b427a55 Poul Sander 2019-02-13 17:49 39
	if(NOT _WIN32_WINNT AND NOT WINVER)
6b427a55 Poul Sander 2019-02-13 17:49 40
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x0601 -DWINVER=0x0601")
6b427a55 Poul Sander 2019-02-13 17:49 41
	endif()
daad7b02 sago007 2016-01-19 19:33 42
endif()
daad7b02 sago007 2016-01-19 19:33 43
ab86a00f sago007 2017-08-31 19:08 44
if (NOT WIN32 AND NOT STANDALONE)
53646537 sago007 2020-05-10 10:18 45
	#The path to the data dir must be compiled into the binary
53646537 sago007 2020-05-10 10:18 46
	if (IS_ABSOLUTE ${INSTALL_DATA_DIR})
53646537 sago007 2020-05-10 10:18 47
		add_definitions(-DSHAREDIR=\"${INSTALL_DATA_DIR}\")
53646537 sago007 2020-05-10 10:18 48
	else()
53646537 sago007 2020-05-10 10:18 49
		add_definitions(-DSHAREDIR=\"${CMAKE_INSTALL_PREFIX}/${INSTALL_DATA_DIR}\")
53646537 sago007 2020-05-10 10:18 50
	endif()
53646537 sago007 2020-05-10 10:18 51
	if (IS_ABSOLUTE ${INSTALL_DATA_DIR})
53646537 sago007 2020-05-10 10:18 52
		add_definitions(-DLOCALEDIR=\"${INSTALL_LOCALE_DIR}\")
53646537 sago007 2020-05-10 10:18 53
	else()
53646537 sago007 2020-05-10 10:18 54
		add_definitions(-DLOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${INSTALL_LOCALE_DIR}\")
53646537 sago007 2020-05-10 10:18 55
	endif()
344e2b89 sago007 2016-01-18 21:33 56
endif()
e566d265 sago007 2016-01-16 14:19 57
d20eb8bb Poul Sander 2022-04-14 20:28 58
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
d20eb8bb Poul Sander 2022-04-14 20:28 59
    set(MACOSX TRUE)
d20eb8bb Poul Sander 2022-04-14 20:28 60
endif()
d20eb8bb Poul Sander 2022-04-14 20:28 61
e566d265 sago007 2016-01-16 14:19 62
#Compiler options
e49cda71 Poul Sander 2019-05-22 15:48 63
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++11")
d9476292 sago007 2016-04-29 17:20 64
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -g -DDEBUG")
e566d265 sago007 2016-01-16 14:19 65
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O2")
e566d265 sago007 2016-01-16 14:19 66
2c2c318c sago007 2016-01-17 15:17 67
#Setup SDL2
e566d265 sago007 2016-01-16 14:19 68
find_package(SDL2 REQUIRED)
e38af775 Poul Sander 2023-01-15 18:27 69
5614ab55 sago007 2016-01-17 13:44 70
2c2c318c sago007 2016-01-17 15:17 71
#Setup things that use pkg-config
5614ab55 sago007 2016-01-17 13:44 72
find_package(PkgConfig REQUIRED)
5614ab55 sago007 2016-01-17 13:44 73
pkg_search_module(SDL2MIXER REQUIRED SDL2_mixer)
5614ab55 sago007 2016-01-17 13:44 74
pkg_search_module(SDL2IMAGE REQUIRED SDL2_image)
5614ab55 sago007 2016-01-17 13:44 75
pkg_search_module(SDL2TTF REQUIRED SDL2_ttf)
5614ab55 sago007 2016-01-17 13:44 76
c8c45c95 Poul Sander 2020-08-15 15:40 77
d20eb8bb Poul Sander 2022-04-14 20:28 78
find_package(Intl REQUIRED)
d20eb8bb Poul Sander 2022-04-14 20:28 79
c8b43ea3 sago007 2016-02-02 18:20 80
find_package(Boost COMPONENTS program_options REQUIRED)
c8b43ea3 sago007 2016-02-02 18:20 81
2c2c318c sago007 2016-01-17 15:17 82
#Find all sources but one
c253d620 Poul Sander 2023-07-13 14:06 83
file(GLOB SOURCES "source/code/*.cpp" "source/code/*.inc" "source/code/*.h*" "source/code/*/*.cpp" "source/code/*/*.h*" "source/code/Libs/*.c" "source/code/Libs/*.h*")
e566d265 sago007 2016-01-16 14:19 84
#I am still trying to get BlockGame to compile as a source file
1f6aecf9 sago007 2016-02-20 12:53 85
#list(REMOVE_ITEM SOURCES "${blockattack_SOURCE_DIR}/source/code/BlockGame.cpp")
2c2c318c sago007 2016-01-17 15:17 86
2c2c318c sago007 2016-01-17 15:17 87
#Some messages to figure out what cmake does
e566d265 sago007 2016-01-16 14:19 88
message("${SOURCES}")
5614ab55 sago007 2016-01-17 13:44 89
message("${CMAKE_EXE_LINKER_FLAGS}")
2c2c318c sago007 2016-01-17 15:17 90
f8deb5b9 Poul Sander 2022-01-15 13:55 91
if (BLOCKATTACK_USE_EMBEDDED_FMT)
f8deb5b9 Poul Sander 2022-01-15 13:55 92
	message("Using embedded {fmt}")
f8deb5b9 Poul Sander 2022-01-15 13:55 93
	add_subdirectory("source/misc/embedded_libs/fmt-8.1.1" EXCLUDE_FROM_ALL)
f8deb5b9 Poul Sander 2022-01-15 13:55 94
	message("Done processing {fmt}")
f8deb5b9 Poul Sander 2022-01-15 13:55 95
endif()
f8deb5b9 Poul Sander 2022-01-15 13:55 96
c74066db Poul Sander 2022-02-16 12:14 97
if (BLOCKATTACK_USE_EMBEDDED_PLATFORM_FOLDERS)
c74066db Poul Sander 2022-02-16 12:14 98
	message("Using embedded PlatformFolders")
c74066db Poul Sander 2022-02-16 12:14 99
	add_subdirectory("source/misc/embedded_libs/PlatformFolders-4.2.0" EXCLUDE_FROM_ALL)
c74066db Poul Sander 2022-02-16 12:14 100
	message("Done processing PlatformFolders")
c74066db Poul Sander 2022-02-16 12:14 101
endif()
c74066db Poul Sander 2022-02-16 12:14 102
7a956470 sago007 2016-02-14 17:09 103
2c2c318c sago007 2016-01-17 15:17 104
#building/compiling/linking
e35cd386 Poul Sander 2023-11-29 20:33 105
add_executable(blockattack ${GUI_TYPE} ${SOURCES} ${RES_FILES}
e35cd386 Poul Sander 2023-11-29 20:33 106
    source/code/menudef_themes.cpp
e35cd386 Poul Sander 2023-11-29 20:33 107
    source/code/menudef_themes.hpp)
e38af775 Poul Sander 2023-01-15 18:27 108
e38af775 Poul Sander 2023-01-15 18:27 109
target_include_directories(blockattack PRIVATE "source/code/Libs/include")
e38af775 Poul Sander 2023-01-15 18:27 110
target_include_directories(blockattack PRIVATE "source/code/Libs/include/cereal/external")  #Contains rapidjson
e38af775 Poul Sander 2023-01-15 18:27 111
target_include_directories(blockattack PRIVATE ${SDL2_INCLUDE_DIRS})
e38af775 Poul Sander 2023-01-15 18:27 112
target_include_directories(blockattack PRIVATE ${SDL2MIXER_INCLUDE_DIRS})
e38af775 Poul Sander 2023-01-15 18:27 113
target_include_directories(blockattack PRIVATE ${SDL2IMAGE_INCLUDE_DIRS})
e38af775 Poul Sander 2023-01-15 18:27 114
target_include_directories(blockattack PRIVATE ${SDL2TTF_INCLUDE_DIRS})
e38af775 Poul Sander 2023-01-15 18:27 115
target_include_directories(blockattack PRIVATE ${Intl_INCLUDE_DIRS})
e38af775 Poul Sander 2023-01-15 18:27 116
e38af775 Poul Sander 2023-01-15 18:27 117
target_link_libraries(blockattack PRIVATE ${SDL2_LIBRARIES})
e38af775 Poul Sander 2023-01-15 18:27 118
target_link_libraries(blockattack PRIVATE fmt)
e38af775 Poul Sander 2023-01-15 18:27 119
target_link_libraries(blockattack PRIVATE platform_folders)
e38af775 Poul Sander 2023-01-15 18:27 120
target_link_libraries(blockattack PRIVATE physfs)
d20eb8bb Poul Sander 2022-04-14 20:28 121
if (MACOSX)
e38af775 Poul Sander 2023-01-15 18:27 122
	target_link_libraries(blockattack PRIVATE intl)
d20eb8bb Poul Sander 2022-04-14 20:28 123
endif()
e38af775 Poul Sander 2023-01-15 18:27 124
target_link_libraries(blockattack PRIVATE ${SDL2MIXER_LIBRARIES} ${SDL2IMAGE_LIBRARIES} ${SDL2TTF_LIBRARIES})
e38af775 Poul Sander 2023-01-15 18:27 125
target_link_libraries(blockattack PRIVATE ${Boost_LIBRARIES} )
e38af775 Poul Sander 2023-01-15 18:27 126
set_target_properties(blockattack PROPERTIES RUNTIME_OUTPUT_DIRECTORY Game)
2c2c318c sago007 2016-01-17 15:17 127
2c2c318c sago007 2016-01-17 15:17 128
#Installing
2c2c318c sago007 2016-01-17 15:17 129
install(TARGETS blockattack RUNTIME DESTINATION ${INSTALL_BIN_DIR} )
2c2c318c sago007 2016-01-17 15:17 130
install(FILES Game/blockattack.data DESTINATION ${INSTALL_DATA_DIR} )
ffe60429 Poul Sander 2022-01-15 10:52 131
install(FILES Game/mods/1.3.0.bricks.data DESTINATION "${INSTALL_DATA_DIR}/mods" )
2c2c318c sago007 2016-01-17 15:17 132
install(FILES man/blockattack.6.gz DESTINATION ${INSTALL_MAN_DIR} )
2c2c318c sago007 2016-01-17 15:17 133
install(FILES source/misc/blockattack.desktop DESTINATION ${INSTALL_APPLICATIONS_DIR} )
28735382 sago007 2019-04-28 11:01 134
install(FILES source/misc/net.blockattack.game.metainfo.xml DESTINATION ${INSTALL_METAINFO_DIR} )
8642f439 Pino Toscano 2021-04-21 18:43 135
install(FILES source/misc/icons/blockattack16.png DESTINATION "${INSTALL_ICONS_DIR}/16x16/apps" RENAME blockattack.png )
8642f439 Pino Toscano 2021-04-21 18:43 136
install(FILES source/misc/icons/blockattack48.png DESTINATION "${INSTALL_ICONS_DIR}/48x48/apps" RENAME blockattack.png )
8642f439 Pino Toscano 2021-04-21 18:43 137
install(FILES source/misc/icons/blockattack128.png DESTINATION "${INSTALL_ICONS_DIR}/128x128/apps" RENAME blockattack.png )
8642f439 Pino Toscano 2021-04-21 18:43 138
install(FILES source/misc/icons/blockattack256.png DESTINATION "${INSTALL_ICONS_DIR}/256x256/apps" RENAME blockattack.png )
8642f439 Pino Toscano 2021-04-21 18:43 139
install(FILES source/misc/icons/blockattack64.png DESTINATION "${INSTALL_ICONS_DIR}/64x64/apps" RENAME blockattack.png )
8642f439 Pino Toscano 2021-04-21 18:43 140
install(FILES source/misc/icons/blockattack32.png DESTINATION "${INSTALL_ICONS_DIR}/32x32/apps" RENAME blockattack.png )
b1a99ae7 Poul Sander 2016-05-27 21:08 141
install(DIRECTORY source/misc/translation/locale/ DESTINATION "${INSTALL_LOCALE_DIR}")
1970-01-01 00:00 142