OpenRCT2/src/openrct2-ui/CMakeLists.txt

75 lines
2.3 KiB
CMake
Raw Normal View History

2017-06-25 15:28:25 +02:00
# CMAKE project for openrct2-ui (UI build of OpenRCT2)
cmake_minimum_required(VERSION 3.1)
2017-03-25 00:40:17 +01:00
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
# Third party libraries
PKG_CHECK_MODULES(SDL2 REQUIRED sdl2)
2017-05-23 16:37:03 +02:00
PKG_CHECK_MODULES(SPEEX REQUIRED speexdsp)
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}/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/*.h"
"${CMAKE_CURRENT_LIST_DIR}/*.hpp")
if (APPLE)
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} CXX)
add_executable(${PROJECT} ${OPENRCT2_UI_SOURCES} ${OPENRCT2_UI_MM_SOURCES})
2017-03-25 00:40:17 +01:00
target_link_libraries(${PROJECT} "libopenrct2"
2017-08-28 22:01:48 +02:00
${SDL2_LDFLAGS}
${SPEEX_LDFLAGS})
2017-05-23 16:37:03 +02:00
if (APPLE)
target_link_libraries(${PROJECT} "-framework Cocoa")
2017-05-23 16:37:03 +02:00
endif ()
2017-03-25 00:40:17 +01:00
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}/.."
2017-05-23 16:37:03 +02:00
${SPEEX_INCLUDE_DIRS})
target_include_directories(${PROJECT} SYSTEM PRIVATE ${SDL2_INCLUDE_DIRS})
2017-03-25 00:40:17 +01:00
# Compiler flags
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 ()
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 ()