Fix OSX build for shared library type.
Documentation clean up. Do not need to remind on the URHO3D_STATIC_DEFINE anymore for downstream projects as it is now baked into the export header.
This commit is contained in:
parent
b90c3ba444
commit
32b0b9de1c
@ -82,6 +82,8 @@ else ()
|
||||
elseif (URHO3D_LIB_TYPE STREQUAL SHARED)
|
||||
if (MINGW)
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES .dll.a)
|
||||
elseif (APPLE)
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES .dylib)
|
||||
else ()
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES .so)
|
||||
endif ()
|
||||
@ -163,10 +165,11 @@ else ()
|
||||
endif ()
|
||||
endif ()
|
||||
elseif (NOT URHO3D_LIB_TYPE)
|
||||
if (URHO3D_LIBRARIES MATCHES \\.\(so|dll\\.a\)$)
|
||||
if (URHO3D_LIBRARIES MATCHES \\.\(so|dll\\.a|dylib\)$)
|
||||
set (URHO3D_LIB_TYPE SHARED)
|
||||
elseif (URHO3D_LIBRARIES MATCHES \\.a$)
|
||||
set (URHO3D_LIB_TYPE STATIC)
|
||||
add_definitions (-DURHO3D_STATIC_DEFINE)
|
||||
endif ()
|
||||
endif ()
|
||||
if (WIN32)
|
||||
|
@ -112,6 +112,7 @@ if (IOS OR (RPI AND "${RPI_ABI}" MATCHES NEON)) # Stringify in case RPI_ABI i
|
||||
endif ()
|
||||
cmake_dependent_option (URHO3D_NEON "Enable NEON instruction set (ARM platforms with NEON only)" TRUE "NEON" FALSE)
|
||||
if (CMAKE_PROJECT_NAME STREQUAL Urho3D)
|
||||
set (URHO3D_LIB_TYPE STATIC CACHE STRING "Specify Urho3D library type, possible values are STATIC (default) and SHARED")
|
||||
cmake_dependent_option (URHO3D_LUAJIT_AMALG "Enable LuaJIT amalgamated build (LuaJIT only)" FALSE "URHO3D_LUAJIT" FALSE)
|
||||
cmake_dependent_option (URHO3D_SAFE_LUA "Enable Lua C++ wrapper safety checks (Lua/LuaJIT only)" FALSE "URHO3D_LUA OR URHO3D_LUAJIT" FALSE)
|
||||
if (CMAKE_BUILD_TYPE STREQUAL Release OR CMAKE_CONFIGURATION_TYPES)
|
||||
@ -138,6 +139,7 @@ if (CMAKE_PROJECT_NAME STREQUAL Urho3D)
|
||||
cmake_dependent_option (URHO3D_USE_LIB_DEB "Enable 64-bit DEB CPack generator using /usr/lib and disable all other generators (Redhat-based host only)" FALSE "URHO3D_64BIT AND HAS_LIB64" FALSE)
|
||||
endif ()
|
||||
else ()
|
||||
set (URHO3D_LIB_TYPE "" CACHE STRING "Specify Urho3D library type, possible values are STATIC and SHARED")
|
||||
set (URHO3D_HOME "" CACHE PATH "Path to Urho3D build tree or SDK installation location (external project only)")
|
||||
if (URHO3D_PCH OR URHO3D_UPDATE_SOURCE_TREE)
|
||||
# Just reference it to suppress "unused variable" CMake warning on external projects using this CMake module
|
||||
@ -206,7 +208,6 @@ endif ()
|
||||
cmake_dependent_option (URHO3D_STATIC_RUNTIME "Use static C/C++ runtime libraries and eliminate the need for runtime DLLs installation (VS only)" FALSE "MSVC" FALSE)
|
||||
cmake_dependent_option (URHO3D_WIN32_CONSOLE "Use console main() as entry point when setting up Windows executable targets (Windows platform only)" FALSE "WIN32" FALSE)
|
||||
cmake_dependent_option (URHO3D_MACOSX_BUNDLE "Use MACOSX_BUNDLE when setting up Mac OS X executable targets (Xcode native build only)" FALSE "XCODE AND NOT IOS" FALSE)
|
||||
set (URHO3D_LIB_TYPE STATIC CACHE STRING "Specify Urho3D library type, possible values are STATIC (default) and SHARED")
|
||||
if (CMAKE_CROSSCOMPILING AND NOT ANDROID)
|
||||
set (URHO3D_SCP_TO_TARGET "" CACHE STRING "Use scp to transfer executables to target system (non-Android cross-compiling build only), SSH digital key must be setup first for this to work, typical value has a pattern of usr@tgt:remote-loc")
|
||||
else ()
|
||||
@ -395,7 +396,7 @@ endif ()
|
||||
if (URHO3D_LIB_TYPE)
|
||||
string (TOUPPER ${URHO3D_LIB_TYPE} URHO3D_LIB_TYPE)
|
||||
endif ()
|
||||
if (NOT URHO3D_LIB_TYPE STREQUAL SHARED)
|
||||
if (NOT URHO3D_LIB_TYPE STREQUAL "" AND NOT URHO3D_LIB_TYPE STREQUAL SHARED)
|
||||
set (URHO3D_LIB_TYPE STATIC)
|
||||
if (NOT MSVC) # This define will be baked into the export header for MSVC compiler
|
||||
add_definitions (-DURHO3D_STATIC_DEFINE)
|
||||
|
@ -548,7 +548,7 @@ setup_main_executable ()
|
||||
|
||||
The CMAKE_MODULE_PATH is setup so that CMake can find the Urho3D-specific CMake modules provided by Urho3D project inside your own project. The Urho3D-CMake-common.cmake is the module where all the reusable commands and macros are defined. It also gives your project cross-platform build capability similar to Urho3D project.
|
||||
|
||||
When both Urho3D static and shared library are built and available in the Urho3D project's library output directory in its build tree, the FindUrho3D.cmake module has precedence to first select static library type over over shared library type. However, you can use URHO3D_LIB_TYPE build option to explicitly specify which Urho3D library type to be selected. When linking statically against Urho3D static library, Urho3D-CMake-common.cmake module automatically set "URHO3D_STATIC_DEFINE" compiler define for your project. This compiler define is crucial for static linking, especially on MSVC. If you do not use our CMake modules to configure your project then you have to ensure you manually set this compiler define in your project.
|
||||
When both Urho3D static and shared library are built and available in the Urho3D project's library output directory in its build tree, the FindUrho3D.cmake module has precedence to first select static library type over over shared library type. However, you can use URHO3D_LIB_TYPE build option to explicitly specify which Urho3D library type to be selected.
|
||||
|
||||
As described earlier there are two approaches on how to find the Urho3D library. The FindUrho3D.cmake module is designed not only able to find Urho3D library from the Urho3D SDK installation, but also from any Urho3D project build tree directly. When searching in Urho3D SDK installed in a system-wide default location then no additional variable need to be set. When searching in a non-default SDK installation or when searching in any Urho3D project build tree then the actual location need to be provided via URHO3D_HOME environment variable (set in the host system) or URHO3D_HOME build option (set using -D at command line or in cmake-gui).
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user