mirror of
https://github.com/minetest/minetest.git
synced 2024-11-29 19:13:44 +01:00
Simplify Irrlicht CMake for static linking
removes any dynamic linking capability, which will stop being possible soon anyway.
This commit is contained in:
parent
8a5e49c856
commit
b9adf244e5
@ -94,10 +94,7 @@ endif()
|
|||||||
if(TRUE)
|
if(TRUE)
|
||||||
message(STATUS "Using imported IrrlichtMt at subdirectory 'irr'")
|
message(STATUS "Using imported IrrlichtMt at subdirectory 'irr'")
|
||||||
if(BUILD_CLIENT)
|
if(BUILD_CLIENT)
|
||||||
# tell IrrlichtMt to create a static library
|
|
||||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared library" FORCE)
|
|
||||||
add_subdirectory(irr EXCLUDE_FROM_ALL)
|
add_subdirectory(irr EXCLUDE_FROM_ALL)
|
||||||
unset(BUILD_SHARED_LIBS CACHE)
|
|
||||||
|
|
||||||
if(NOT TARGET IrrlichtMt)
|
if(NOT TARGET IrrlichtMt)
|
||||||
message(FATAL_ERROR "IrrlichtMt project is missing a CMake target?!")
|
message(FATAL_ERROR "IrrlichtMt project is missing a CMake target?!")
|
||||||
|
@ -1,82 +1,24 @@
|
|||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.12)
|
||||||
|
|
||||||
set(IRRLICHTMT_REVISION 15)
|
project(Irrlicht LANGUAGES CXX)
|
||||||
|
|
||||||
project(Irrlicht
|
message(STATUS "*** Building IrrlichtMt ***")
|
||||||
VERSION 1.9.0.${IRRLICHTMT_REVISION}
|
|
||||||
LANGUAGES CXX
|
|
||||||
)
|
|
||||||
|
|
||||||
message(STATUS "*** Building IrrlichtMt ${PROJECT_VERSION} ***")
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
|
||||||
|
|
||||||
if(ANDROID)
|
|
||||||
set(sysname Android)
|
|
||||||
elseif(APPLE)
|
|
||||||
set(sysname OSX)
|
|
||||||
elseif(MSVC)
|
|
||||||
set(sysname Win32-VisualStudio)
|
|
||||||
elseif(WIN32)
|
|
||||||
set(sysname Win32-gcc)
|
|
||||||
else()
|
|
||||||
set(sysname Linux)
|
|
||||||
endif()
|
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib/${sysname})
|
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/${sysname})
|
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# FIXME: tests need to be moved to MT if we want to keep them
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
enable_testing()
|
#enable_testing()
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(test)
|
#add_subdirectory(test)
|
||||||
|
|
||||||
option(BUILD_EXAMPLES "Build example applications" FALSE)
|
#option(BUILD_EXAMPLES "Build example applications" FALSE)
|
||||||
if(BUILD_EXAMPLES)
|
#if(BUILD_EXAMPLES)
|
||||||
add_subdirectory(examples)
|
# add_subdirectory(examples)
|
||||||
endif()
|
#endif()
|
||||||
|
|
||||||
# Export a file that describes the targets that IrrlichtMt creates.
|
|
||||||
# The file is placed in the location FILE points to, where CMake can easily
|
|
||||||
# locate it by pointing CMAKE_PREFIX_PATH to this project root.
|
|
||||||
export(EXPORT IrrlichtMt-export
|
|
||||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtTargets.cmake"
|
|
||||||
NAMESPACE IrrlichtMt::
|
|
||||||
)
|
|
||||||
|
|
||||||
# Installation of headers.
|
|
||||||
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/"
|
|
||||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/irrlichtmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Installation of CMake target and configuration files.
|
|
||||||
install(EXPORT IrrlichtMt-export
|
|
||||||
FILE IrrlichtMtTargets.cmake
|
|
||||||
NAMESPACE IrrlichtMt::
|
|
||||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IrrlichtMt"
|
|
||||||
)
|
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
|
||||||
configure_package_config_file("${PROJECT_SOURCE_DIR}/Config.cmake.in"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtConfig.cmake"
|
|
||||||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IrrlichtMt"
|
|
||||||
NO_SET_AND_CHECK_MACRO
|
|
||||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
|
||||||
)
|
|
||||||
write_basic_package_version_file(
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtConfigVersion.cmake"
|
|
||||||
COMPATIBILITY AnyNewerVersion
|
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtConfig.cmake"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtConfigVersion.cmake"
|
|
||||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IrrlichtMt"
|
|
||||||
)
|
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
@PACKAGE_INIT@
|
|
||||||
|
|
||||||
include(CMakeFindDependencyMacro)
|
|
||||||
|
|
||||||
if(NOT TARGET IrrlichtMt::IrrlichtMt)
|
|
||||||
# private dependency only explicitly needed with static libs
|
|
||||||
if(@USE_SDL2@ AND NOT @BUILD_SHARED_LIBS@)
|
|
||||||
find_dependency(SDL2)
|
|
||||||
endif()
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/IrrlichtMtTargets.cmake")
|
|
||||||
endif()
|
|
@ -18,37 +18,13 @@ The following libraries are required to be installed:
|
|||||||
* SDL2 (see below)
|
* SDL2 (see below)
|
||||||
|
|
||||||
Aside from standard search options (`ZLIB_INCLUDE_DIR`, `ZLIB_LIBRARY`, ...) the following options are available:
|
Aside from standard search options (`ZLIB_INCLUDE_DIR`, `ZLIB_LIBRARY`, ...) the following options are available:
|
||||||
* `BUILD_SHARED_LIBS` (default: `ON`) - Build IrrlichtMt as a shared library
|
|
||||||
* `BUILD_EXAMPLES` (default: `OFF`) - Build example applications
|
|
||||||
* `ENABLE_OPENGL` - Enable OpenGL driver
|
* `ENABLE_OPENGL` - Enable OpenGL driver
|
||||||
* `ENABLE_OPENGL3` (default: `OFF`) - Enable OpenGL 3+ driver
|
* `ENABLE_OPENGL3` (default: `OFF`) - Enable OpenGL 3+ driver
|
||||||
* `ENABLE_GLES1` - Enable OpenGL ES driver, legacy
|
* `ENABLE_GLES1` - Enable OpenGL ES driver, legacy
|
||||||
* `ENABLE_GLES2` - Enable OpenGL ES 2+ driver
|
* `ENABLE_GLES2` - Enable OpenGL ES 2+ driver
|
||||||
* `USE_SDL2` (default: platform-dependent, usually `ON`) - Use SDL2 instead of older native device code
|
* `USE_SDL2` (default: platform-dependent, usually `ON`) - Use SDL2 instead of older native device code
|
||||||
|
|
||||||
e.g. on a Linux system you might want to build for local use like this:
|
However, IrrlichtMt cannot be built or installed separately.
|
||||||
|
|
||||||
git clone https://github.com/minetest/irrlicht
|
|
||||||
cd irrlicht
|
|
||||||
cmake . -DBUILD_SHARED_LIBS=OFF
|
|
||||||
make -j$(nproc)
|
|
||||||
|
|
||||||
This will put an IrrlichtMtTargets.cmake file into the cmake directory in the current build directory, and it can then be imported from another project by pointing `find_package()` to the build directory, or by setting the `CMAKE_PREFIX_PATH` variable to that same path.
|
|
||||||
|
|
||||||
on Windows system:
|
|
||||||
|
|
||||||
It is highly recommended to use vcpkg as package manager.
|
|
||||||
|
|
||||||
After you successfully built vcpkg you can easily install the required libraries:
|
|
||||||
|
|
||||||
vcpkg install zlib libjpeg-turbo libpng sdl2 --triplet x64-windows
|
|
||||||
|
|
||||||
Run the following script in PowerShell:
|
|
||||||
|
|
||||||
git clone https://github.com/minetest/irrlicht
|
|
||||||
cd irrlicht
|
|
||||||
cmake -B build -G "Visual Studio 17 2022" -A "Win64" -DCMAKE_TOOLCHAIN_FILE=[vcpkg-root]/scripts/buildsystems/vcpkg.cmake -DBUILD_SHARED_LIBS=OFF
|
|
||||||
cmake --build build --config Release
|
|
||||||
|
|
||||||
Platforms
|
Platforms
|
||||||
---------
|
---------
|
||||||
|
@ -4,12 +4,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef _WIN32
|
// these are obsolete and never pre-defined
|
||||||
#define IRRCALLCONV __stdcall
|
|
||||||
#else
|
#define IRRCALLCONV
|
||||||
#define IRRCALLCONV
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef IRRLICHT_API
|
|
||||||
#define IRRLICHT_API
|
#define IRRLICHT_API
|
||||||
#endif
|
|
||||||
|
@ -2,24 +2,10 @@ if(NOT APPLE)
|
|||||||
set(DEFAULT_SDL2 ON)
|
set(DEFAULT_SDL2 ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(BUILD_SHARED_LIBS "Build shared library" TRUE)
|
|
||||||
option(USE_SDL2 "Use the SDL2 backend" ${DEFAULT_SDL2})
|
option(USE_SDL2 "Use the SDL2 backend" ${DEFAULT_SDL2})
|
||||||
|
|
||||||
# Compiler flags
|
# Compiler flags
|
||||||
|
|
||||||
add_definitions(-DIRRLICHT_EXPORTS)
|
|
||||||
if(BUILD_SHARED_LIBS)
|
|
||||||
if(WIN32)
|
|
||||||
set(API_IMPORT "__declspec(dllimport)")
|
|
||||||
set(API_EXPORT "__declspec(dllexport)")
|
|
||||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
|
|
||||||
set(API_EXPORT "__attribute__ ((visibility(\"default\")))") # only necessary if default visibility is set to hidden
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
add_definitions(-D_IRR_STATIC_LIB_)
|
|
||||||
endif()
|
|
||||||
add_definitions("-DIRRLICHT_API=${API_EXPORT}")
|
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
add_definitions(-D_DEBUG)
|
add_definitions(-D_DEBUG)
|
||||||
endif()
|
endif()
|
||||||
@ -493,7 +479,7 @@ add_library(IRRGUIOBJ OBJECT
|
|||||||
|
|
||||||
# Library
|
# Library
|
||||||
|
|
||||||
add_library(IrrlichtMt)
|
add_library(IrrlichtMt STATIC)
|
||||||
foreach(object_lib
|
foreach(object_lib
|
||||||
IRRMESHOBJ IRROBJ IRRVIDEOOBJ
|
IRRMESHOBJ IRROBJ IRRVIDEOOBJ
|
||||||
IRRIOOBJ IRROTHEROBJ IRRGUIOBJ)
|
IRRIOOBJ IRROTHEROBJ IRRGUIOBJ)
|
||||||
@ -510,7 +496,6 @@ target_include_directories(IrrlichtMt
|
|||||||
PUBLIC
|
PUBLIC
|
||||||
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>"
|
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>"
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/irrlichtmt>"
|
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${link_includes}
|
${link_includes}
|
||||||
)
|
)
|
||||||
@ -540,21 +525,6 @@ target_link_libraries(IrrlichtMt PRIVATE
|
|||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) # used in _IRR_DEBUG_BREAK_IF definition in a public header
|
target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) # used in _IRR_DEBUG_BREAK_IF definition in a public header
|
||||||
endif()
|
endif()
|
||||||
target_compile_definitions(IrrlichtMt INTERFACE "IRRLICHT_API=${API_IMPORT}")
|
|
||||||
if(APPLE OR ANDROID OR EMSCRIPTEN)
|
if(APPLE OR ANDROID OR EMSCRIPTEN)
|
||||||
target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS)
|
target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_target_properties(IrrlichtMt PROPERTIES
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
)
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
set_target_properties(IrrlichtMt PROPERTIES PREFIX "") # for DLL name
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Installation of library
|
|
||||||
install(TARGETS IrrlichtMt
|
|
||||||
EXPORT IrrlichtMt-export
|
|
||||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
||||||
)
|
|
||||||
|
@ -4,13 +4,6 @@
|
|||||||
|
|
||||||
static const char *const copyright = "Irrlicht Engine (c) 2002-2017 Nikolaus Gebhardt"; // put string in binary
|
static const char *const copyright = "Irrlicht Engine (c) 2002-2017 Nikolaus Gebhardt"; // put string in binary
|
||||||
|
|
||||||
#ifdef _IRR_WINDOWS_
|
|
||||||
#include <windows.h>
|
|
||||||
#if defined(_DEBUG) && !defined(__GNUWIN32__)
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#endif // _DEBUG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "irrlicht.h"
|
#include "irrlicht.h"
|
||||||
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||||
#include "CIrrDeviceWin32.h"
|
#include "CIrrDeviceWin32.h"
|
||||||
@ -126,27 +119,3 @@ extern "C" IRRLICHT_API bool IRRCALLCONV isDriverSupported(E_DRIVER_TYPE driver)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace irr
|
} // end namespace irr
|
||||||
|
|
||||||
#if defined(_IRR_WINDOWS_API_) && !defined(_IRR_STATIC_LIB_)
|
|
||||||
|
|
||||||
BOOL APIENTRY DllMain(HANDLE hModule,
|
|
||||||
DWORD ul_reason_for_call,
|
|
||||||
LPVOID lpReserved)
|
|
||||||
{
|
|
||||||
// _crtBreakAlloc = 139;
|
|
||||||
|
|
||||||
switch (ul_reason_for_call) {
|
|
||||||
case DLL_PROCESS_ATTACH:
|
|
||||||
#if defined(_DEBUG) && !defined(__GNUWIN32__)
|
|
||||||
_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case DLL_THREAD_ATTACH:
|
|
||||||
case DLL_THREAD_DETACH:
|
|
||||||
case DLL_PROCESS_DETACH:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // defined(_IRR_WINDOWS_)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user