OpenRCT2/src/openrct2-ui/CMakeLists.txt

82 lines
2.6 KiB
CMake
Raw Normal View History

2017-03-25 00:40:17 +01:00
# CMAKE project for openrct2-cli (UI build of OpenRCT2)
cmake_minimum_required(VERSION 2.6)
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt")
2017-03-25 02:40:16 +01:00
endif ()
# Options
option(DISABLE_OPENGL "Disable OpenGL support.")
2017-03-25 00:40:17 +01:00
# CMake dependencies
include(FindPkgConfig)
# Third party libraries
PKG_CHECK_MODULES(SDL2 REQUIRED sdl2)
2017-03-25 02:40:16 +01:00
if (NOT DISABLE_OPENGL)
# GL doesn't work nicely with macOS, while find_package doesn't work with multiarch on Ubuntu.
if (APPLE)
find_package(OpenGL REQUIRED)
elseif (NOT WIN32)
PKG_CHECK_MODULES(GL REQUIRED gl)
endif ()
endif ()
2017-03-25 00:40:17 +01:00
# Sources
2017-03-25 02:40:16 +01:00
file(GLOB_RECURSE OPENRCT2_UI_SOURCES
2017-03-25 00:40:17 +01:00
"${CMAKE_CURRENT_LIST_DIR}/*.c"
"${CMAKE_CURRENT_LIST_DIR}/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/*.h"
"${CMAKE_CURRENT_LIST_DIR}/*.hpp")
if (APPLE)
file(GLOB_RECURSE OPENRCT2_UI_M_SOURCES "${CMAKE_CURRENT_LIST_DIR}/*.m")
set_source_files_properties(${OPENRCT2_UI_M_SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c -fmodules")
file(GLOB_RECURSE OPENRCT2_UI_MM_SOURCES "${CMAKE_CURRENT_LIST_DIR}/*.mm")
set_source_files_properties(${OPENRCT2_UI_MM_SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c++ -fmodules")
endif ()
2017-03-25 00:40:17 +01:00
# Outputs
set (PROJECT openrct2)
project(${PROJECT})
add_executable(${PROJECT} ${OPENRCT2_UI_SOURCES} ${OPENRCT2_UI_M_SOURCES} ${OPENRCT2_UI_MM_SOURCES})
2017-03-25 00:40:17 +01:00
target_link_libraries(${PROJECT} "libopenrct2"
${SDL2_LIBRARIES}
${SDL2_TTF_LIBRARIES})
2017-03-25 02:40:16 +01:00
if (NOT DISABLE_OPENGL)
if (WIN32)
target_link_libraries(${PROJECT} opengl32)
elseif (APPLE)
target_link_libraries(${PROJECT} ${OPENGL_LIBRARY})
else ()
target_link_libraries(${PROJECT} ${GL_LIBRARIES})
endif ()
endif ()
2017-03-25 00:40:17 +01:00
# Includes
target_include_directories(${PROJECT} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/.."
${SDL2_INCLUDE_DIRS})
# Compiler flags
if (FORCE32)
set(TARGET_M "-m32")
endif ()
2017-03-25 02:40:16 +01:00
if (WIN32)
# mingw complains about "%zu" not being a valid format specifier for printf, unless we
# tell it that it is
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__USE_MINGW_ANSI_STDIO=1")
endif ()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 ${TARGET_M}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14 ${TARGET_M}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${TARGET_M}")
2017-03-25 00:40:17 +01:00
2017-03-25 02:40:16 +01:00
# Defines
if (DISABLE_OPENGL)
add_definitions(-DDISABLE_OPENGL)
else ()
# Makes OpenGL function get queried in run-time rather than linked-in
add_definitions(-DOPENGL_NO_LINK)
endif ()