mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Create new CMake project for libopenrct2
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
# CMAKE project for openrct2-cli (CLI-only 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")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_M} -std=gnu11 ${COMMON_COMPILE_OPTIONS} -Wimplicit")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_M} -std=gnu++14 ${COMMON_COMPILE_OPTIONS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} ${PIE_FLAG}")
|
||||
|
||||
INCLUDE_DIRECTORIES(SYSTEM ${OPENRCT2_CORE})
|
||||
|
||||
set (PROJECT openrct2)
|
||||
project(${PROJECT})
|
||||
# Includes
|
||||
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
|
||||
# Sources
|
||||
file(GLOB_RECURSE OPENRCT2_CLI_SOURCES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
|
||||
|
||||
# install into ${CMAKE_INSTALL_PREFIX}/bin/
|
||||
#install (TARGETS ${PROJECT} DESTINATION bin)
|
||||
# Compiler flags
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_M} -std=gnu11 ${COMMON_COMPILE_OPTIONS} -Wimplicit")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_M} -std=gnu++14 ${COMMON_COMPILE_OPTIONS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} ${PIE_FLAG}")
|
||||
|
||||
# Outputs
|
||||
set (PROJECT openrct2)
|
||||
project(${PROJECT})
|
||||
add_executable(${PROJECT} ${OPENRCT2_CLI_SOURCES})
|
||||
|
||||
57
src/openrct2/CMakeLists.txt
Normal file
57
src/openrct2/CMakeLists.txt
Normal file
@@ -0,0 +1,57 @@
|
||||
# CMAKE project for libopenrct2 (core OpenRCT2 component)
|
||||
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")
|
||||
endif()
|
||||
|
||||
# CMake dependencies
|
||||
INCLUDE(FindPkgConfig)
|
||||
|
||||
# Third party libraries
|
||||
PKG_CHECK_MODULES(JANSSON REQUIRED jansson>=2.5)
|
||||
PKG_CHECK_MODULES(LIBCURL REQUIRED libcurl)
|
||||
PKG_CHECK_MODULES(LIBZIP REQUIRED libzip>=1.0)
|
||||
PKG_CHECK_MODULES(SSL REQUIRED openssl>=1.0.0)
|
||||
PKG_CHECK_MODULES(PNG libpng>=1.6)
|
||||
PKG_CHECK_MODULES(ZLIB REQUIRED zlib)
|
||||
|
||||
# Third party libraries (which we want to eventually remove from libopenrct2)
|
||||
PKG_CHECK_MODULES(FONTCONFIG REQUIRED fontconfig)
|
||||
PKG_CHECK_MODULES(SDL2 REQUIRED sdl2)
|
||||
PKG_CHECK_MODULES(SDL2_TTF REQUIRED SDL2_ttf)
|
||||
PKG_CHECK_MODULES(SPEEX REQUIRED speexdsp)
|
||||
PKG_CHECK_MODULES(GL REQUIRED gl)
|
||||
|
||||
message(STATUS "SDL: ${SDL2_INCLUDE_DIRS}")
|
||||
message(STATUS "SSL: ${SSL_INCLUDE_DIRS}")
|
||||
message(STATUS "TTF: ${SDL2_TTF_INCLUDE_DIRS}")
|
||||
|
||||
# Includes
|
||||
INCLUDE_DIRECTORIES(SYSTEM ${LIBZIP_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS}
|
||||
${LIBCURL_INCLUDE_DIRS}
|
||||
${JANSSON_INCLUDE_DIRS}
|
||||
${SPEEX_INCLUDE_DIRS}
|
||||
${PNG_INCLUDE_DIRS}
|
||||
${ZLIB_INCLUDE_DIRS}
|
||||
${BREAKPAD_INCLUDE_DIR}
|
||||
${SSL_INCLUDE_DIRS}
|
||||
${FONTCONFIG_INCLUDE_DIRS})
|
||||
|
||||
# Sources
|
||||
file(GLOB_RECURSE OPENRCT2_CORE_SOURCES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
|
||||
|
||||
# Compiler flags
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_M} -std=gnu11 ${COMMON_COMPILE_OPTIONS} -Wimplicit")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_M} -std=gnu++14 ${COMMON_COMPILE_OPTIONS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} ${PIE_FLAG}")
|
||||
|
||||
# Outputs
|
||||
set (PROJECT openrct2)
|
||||
project(${PROJECT})
|
||||
add_library(${PROJECT} SHARED ${OPENRCT2_CORE_SOURCES})
|
||||
@@ -38,7 +38,13 @@ public:
|
||||
|
||||
sint32 RunOpenRCT2(int argc, char * * argv) override
|
||||
{
|
||||
return ::RunOpenRCT2(argc, argv);
|
||||
core_init();
|
||||
int runGame = cmdline_run((const char * *)argv, argc);
|
||||
if (runGame == 1)
|
||||
{
|
||||
openrct2_launch();
|
||||
}
|
||||
return gExitCode;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <openrct2/common.h>
|
||||
#include "common.h"
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
|
||||
@@ -87,10 +87,6 @@ extern "C"
|
||||
|
||||
sint32 cmdline_run(const char * * argv, sint32 argc);
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
int RunOpenRCT2(int argc, char * * argv);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include <stdexcept>
|
||||
#include "../core/Exception.hpp"
|
||||
#include "../core/Registration.hpp"
|
||||
#include "IDrawingContext.h"
|
||||
|
||||
@@ -57,23 +57,12 @@ utf8 **windows_get_command_line_args(sint32 *outNumArgs);
|
||||
|
||||
static HMODULE _dllModule = NULL;
|
||||
|
||||
/**
|
||||
* Windows entry point to OpenRCT2 with a console window using a traditional C main function.
|
||||
*/
|
||||
sint32 RunOpenRCT2(int argc, char * * argv)
|
||||
static HMODULE plaform_get_dll_module()
|
||||
{
|
||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||
_dllModule = hInstance;
|
||||
|
||||
core_init();
|
||||
|
||||
sint32 exitCode = cmdline_run((const char **)argv, argc);
|
||||
if (exitCode == 1) {
|
||||
openrct2_launch();
|
||||
exitCode = gExitCode;
|
||||
if (_dllModule == NULL) {
|
||||
_dllModule = GetModuleHandle(NULL);
|
||||
}
|
||||
|
||||
return exitCode;
|
||||
return _dllModule;
|
||||
}
|
||||
|
||||
#ifdef NO_RCT2
|
||||
@@ -817,8 +806,9 @@ HWND windows_get_window_handle()
|
||||
|
||||
void platform_init_window_icon()
|
||||
{
|
||||
if (_dllModule != NULL) {
|
||||
HICON icon = LoadIcon(_dllModule, MAKEINTRESOURCE(IDI_ICON));
|
||||
HMODULE module = plaform_get_dll_module();
|
||||
if (module != NULL) {
|
||||
HICON icon = LoadIcon(module, MAKEINTRESOURCE(IDI_ICON));
|
||||
if (icon != NULL) {
|
||||
HWND hwnd = windows_get_window_handle();
|
||||
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)icon);
|
||||
@@ -1134,7 +1124,7 @@ static bool windows_setup_file_association(
|
||||
sint32 printResult;
|
||||
|
||||
GetModuleFileNameW(NULL, exePathW, sizeof(exePathW));
|
||||
GetModuleFileNameW(_dllModule, dllPathW, sizeof(dllPathW));
|
||||
GetModuleFileNameW(plaform_get_dll_module(), dllPathW, sizeof(dllPathW));
|
||||
|
||||
wchar_t *extensionW = utf8_to_widechar(extension);
|
||||
wchar_t *fileTypeTextW = utf8_to_widechar(fileTypeText);
|
||||
|
||||
Reference in New Issue
Block a user