summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-04-18 11:57:40 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-04-20 17:52:51 +0200
commitb028cb59a7723ca3b7d2ffb5229750413e936e22 (patch)
treeb6bff8243cdef19fffd7873ca39fe08497960b6b /src
parentc74052c766df01eafc3cb5f98c46d779bee8b0e9 (diff)
downloadmana-b028cb59a7723ca3b7d2ffb5229750413e936e22.tar.gz
mana-b028cb59a7723ca3b7d2ffb5229750413e936e22.tar.bz2
mana-b028cb59a7723ca3b7d2ffb5229750413e936e22.tar.xz
mana-b028cb59a7723ca3b7d2ffb5229750413e936e22.zip
CMake: Use add_compile_definitions instead of setting COMPILE_FLAGS
This is supported since CMake 3.12 (current minimum) and simplifies the whole quoting business. Also used a generator expression to set the DEBUG define conditionally. At the same time, DEBUG is no longer defined in RelWithDebInfo builds, but it shouldn't be.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 84ea1ad7..3a35d6dc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -21,22 +21,23 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif()
endif()
-set(FLAGS "-DPACKAGE_VERSION=\\\"${VERSION}\\\"")
+add_compile_definitions(PACKAGE_VERSION="${PROJECT_VERSION}"
+ $<$<CONFIG:Debug>:DEBUG>)
if(WIN32)
- set(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${CMAKE_INSTALL_DATADIR}/\\\"")
- set(FLAGS "${FLAGS} -DLOCALEDIR=\\\"${CMAKE_INSTALL_LOCALEDIR}/\\\"")
+ add_compile_definitions(PKG_DATADIR="${CMAKE_INSTALL_DATADIR}/"
+ LOCALEDIR="${CMAKE_INSTALL_LOCALEDIR}/")
elseif(NOT APPLE)
- set(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${CMAKE_INSTALL_FULL_DATADIR}/\\\"")
- set(FLAGS "${FLAGS} -DLOCALEDIR=\\\"${CMAKE_INSTALL_FULL_LOCALEDIR}/\\\"")
+ add_compile_definitions(PKG_DATADIR="${CMAKE_INSTALL_FULL_DATADIR}/"
+ LOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}/")
endif()
if(ENABLE_MANASERV)
include_directories("../libs/enet/include")
link_directories("../libs/enet")
- set(INTERNAL_LIBRARIES enet)
+ set(ENET_LIBRARY enet)
- set(FLAGS "${FLAGS} -DMANASERV_SUPPORT=1")
+ add_compile_definitions(MANASERV_SUPPORT=1)
message(STATUS "Manaserv support enabled")
endif()
@@ -51,19 +52,10 @@ else()
endif()
if(ENABLE_NLS)
- set(FLAGS "${FLAGS} -DENABLE_NLS=1")
+ add_compile_definitions(ENABLE_NLS=1)
message(STATUS "i18n support enabled")
endif()
-if(CMAKE_BUILD_TYPE)
- string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
- if(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug OR CMAKE_BUILD_TYPE_TOLOWER MATCHES
- relwithdebinfo)
- set(FLAGS "${FLAGS} -DDEBUG")
- message(STATUS "Set Debug build type")
- endif()
-endif()
-
if(WIN32)
set(EXTRA_LIBRARIES ws2_32 winmm)
find_package(LibIntl REQUIRED)
@@ -77,7 +69,7 @@ endif()
if(WITH_OPENGL)
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
- set(FLAGS "${FLAGS} -DUSE_OPENGL")
+ add_compile_definitions(USE_OPENGL)
message(STATUS "OpenGL support enabled")
endif(WITH_OPENGL)
@@ -631,7 +623,7 @@ endif(ENABLE_MANASERV)
target_link_libraries(
mana
- PRIVATE ${INTERNAL_LIBRARIES}
+ PRIVATE ${ENET_LIBRARY}
${SDL2_LINK_LIBRARIES}
${PNG_LIBRARIES}
${PHYSFS_LIBRARY}
@@ -644,8 +636,7 @@ target_link_libraries(
set_target_properties(
mana
- PROPERTIES COMPILE_FLAGS "${FLAGS}"
- MACOSX_BUNDLE TRUE
+ PROPERTIES MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME}
MACOSX_BUNDLE_GUI_IDENTIFIER org.manasource.Mana
MACOSX_BUNDLE_ICON_FILE ${APP_ICON_NAME}