Fix SDK destination installation path for Windows platform.

It appears CMake has automatically prepended "Urho3D" to built-in CMAKE_INSTALL_PREFIX variable, so we don't need to prefix the path one more time. Also in the commits:
- Fix documentation on CMake module search path for Windows platform.
- Unified SDK destination installation for Windows and non-Windows platforms.
- Replace global include directories to SDL and export header to locally scoped include directories.
- Enhance Urho3D.pc generation to also provide additional compiler flags for DEBUG/RELEASE/RELWITHDEBINFO as comments/references.
This commit is contained in:
Yao Wei Tjong 姚伟忠 2013-11-20 15:59:38 +08:00
parent 3c2110b81a
commit f6186456a0
6 changed files with 46 additions and 27 deletions

View File

@ -340,7 +340,7 @@ In your own project Source/ directory, create a new CMakeLists.txt file similar
\code
# Set CMake modules search path
set (CMAKE_MODULE_PATH "$ENV{URHO3D_INSTALL_PREFIX}/Urho3D SDK/CMake/Modules" "${CMAKE_INSTALL_PREFIX}/Urho3D SDK/CMake/Modules" CACHE PATH "Path to Urho3D-specific CMake modules")
set (CMAKE_MODULE_PATH $ENV{URHO3D_INSTALL_PREFIX}/share/CMake/Modules ${CMAKE_INSTALL_PREFIX}/share/CMake/Modules CACHE PATH "Path to Urho3D-specific CMake modules")
\endcode
On non-Windows platform:

View File

@ -87,14 +87,14 @@ if (URHO3D_HOME)
else ()
# If Urho3D SDK is not being installed in the default system location, use the URHO3D_INSTALL_PREFIX environment variable to specify the prefix path to that location
# Note that the prefix path should not contain the "/include" or "/lib"
# For example on Linux platform: URHO3D_INSTALL_PREFIX=/home/john/usr/local if the SDK is installed using DESTDIR=/home/john and CMAKE_INSTALL_PREFIX=/usr/local (default)
# For example on Windows platform: URHO3D_INSTALL_PREFIX=C:/Users/john/Urho3D if the SDK is installed using CMAKE_INSTALL_PREFIX=C:/Users/john/Urho3D
# For example on Linux platform: URHO3D_INSTALL_PREFIX=/home/john/usr/local if the SDK is installed using DESTDIR=/home/john and CMAKE_INSTALL_PREFIX=/usr/local
set (CMAKE_PREFIX_PATH $ENV{URHO3D_INSTALL_PREFIX} CACHE PATH "Prefix path to Urho3D SDK installation")
if (WIN32)
set (PATH_PREFIX "Urho3D SDK")
set (URHO3D_INC_SEARCH_PATH ${PATH_PREFIX}/Include)
set (URHO3D_LIB_SEARCH_PATH ${PATH_PREFIX}/Lib)
set (URHO3D_INC_SEARCH_PATH include)
set (URHO3D_LIB_SEARCH_PATH lib)
else ()
set (PATH_SUFFIX Urho3D) # This could be patched to "" if the suffix is not desirable
set (PATH_SUFFIX Urho3D)
if (IOS)
set (CMAKE_LIBRARY_ARCHITECTURE ios)
endif ()

View File

@ -45,20 +45,12 @@ endif ()
# Setup SDK install destinations
if (WIN32)
set (PATH_PREFIX "Urho3D SDK")
set (DEST_INCLUDE_DIR ${PATH_PREFIX}/Include)
set (DEST_RUNTIME_DIR ${PATH_PREFIX}/Bin)
set (DEST_LIBRARY_DIR ${PATH_PREFIX}/Lib)
set (DEST_ARCHIVE_DIR ${PATH_PREFIX}/Lib)
set (DEST_SHARE_DIR ${PATH_PREFIX})
set (DEST_PKGCONFIG_DIR ${PATH_PREFIX}/Lib/pkgconfig)
# CMake already automatically prepends "Urho3D" to CMAKE_INSTALL_PREFIX on Windows platform
set (SCRIPT_PATTERN *.bat)
else ()
set (PATH_SUFFIX /Urho3D)
set (DEST_INCLUDE_DIR include${PATH_SUFFIX})
set (DEST_RUNTIME_DIR share${PATH_SUFFIX}/Bin)
if (ENABLE_64BIT)
if (NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/lib64) # TODO: Revisit this again when ARM also supports 64bit, for now ARM architecture ignores ENABLE_64BIT build option
if (ENABLE_64BIT) # TODO: Revisit this again when ARM also supports 64bit, for now ARM architecture ignores ENABLE_64BIT build option
if (NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/lib64)
# Probably target system is a RedHat-based distro
set (LIB_SUFFIX 64)
endif ()
@ -67,12 +59,13 @@ else ()
# Use 'ios' arch subdirectory to differentiate, in case both Mac OS X and iOS build are installed at the same destination
set (LIB_SUFFIX ${LIB_SUFFIX}/ios)
endif ()
set (DEST_LIBRARY_DIR lib${LIB_SUFFIX}${PATH_SUFFIX}) # The ${PATH_SUFFIX} could be removed if the suffix is not desirable
set (DEST_ARCHIVE_DIR lib${LIB_SUFFIX}${PATH_SUFFIX}) # idem
set (DEST_SHARE_DIR share${PATH_SUFFIX})
set (DEST_PKGCONFIG_DIR lib${LIB_SUFFIX}/pkgconfig)
set (SCRIPT_PATTERN *.sh)
endif ()
set (DEST_INCLUDE_DIR include${PATH_SUFFIX})
set (DEST_SHARE_DIR share${PATH_SUFFIX})
set (DEST_RUNTIME_DIR ${DEST_SHARE_DIR}/Bin)
set (DEST_LIBRARY_DIR lib${LIB_SUFFIX}${PATH_SUFFIX}) # Note to Linux package maintainer: ${PATH_SUFFIX} for library could be patched out if the suffix is not desirable
set (DEST_PKGCONFIG_DIR lib${LIB_SUFFIX}/pkgconfig)
# Install application launcher scripts
file (GLOB APP_SCRIPTS ${PROJECT_ROOT_DIR}/Bin/${SCRIPT_PATTERN})
install (FILES ${APP_SCRIPTS} DESTINATION ${DEST_RUNTIME_DIR} PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) # 755

View File

@ -118,6 +118,8 @@ set_source_files_properties (${ALL_OBJ_FILES} PROPERTIES GENERATED TRUE)
foreach (LIST_NAME LIBS INCLUDE_DIRS_ONLY LINK_LIBS_ONLY)
set_list (${LIST_NAME} ENGINE_${LIST_NAME} REMOVE_DUPLICATE)
endforeach ()
# Add include directory to find the export header
list (APPEND INCLUDE_DIRS_ONLY ${CMAKE_BINARY_DIR}/Engine)
# Setup library output path
set (OUTPUT_PATH ${PROJECT_ROOT_DIR}/Lib)
@ -130,7 +132,7 @@ set_output_directories (${OUTPUT_PATH} ARCHIVE LIBRARY)
# Setup target
setup_library (${URHO3D_LIB_TYPE})
install (TARGETS ${TARGET_NAME} RUNTIME DESTINATION ${DEST_RUNTIME_DIR} LIBRARY DESTINATION ${DEST_LIBRARY_DIR} ARCHIVE DESTINATION ${DEST_ARCHIVE_DIR})
install (TARGETS ${TARGET_NAME} RUNTIME DESTINATION ${DEST_RUNTIME_DIR} LIBRARY DESTINATION ${DEST_LIBRARY_DIR} ARCHIVE DESTINATION ${DEST_LIBRARY_DIR})
if (NOT GIT_EXIT_CODE EQUAL 0)
add_dependencies (${TARGET_NAME} ${STATIC_LIBRARY_TARGETS})
endif ()
@ -185,9 +187,6 @@ if (URHO3D_LIB_TYPE STREQUAL SHARED)
set_target_properties (${STATIC_LIBRARY_TARGETS} PROPERTIES POSITION_INDEPENDENT_CODE true)
endif ()
# Add include directories to find the export header and SDL header for building Urho3D library
include_directories (${CMAKE_BINARY_DIR}/Engine ../ThirdParty/SDL/include)
# Define post build steps
# Strip the output shared library for embedded devices
if (URHO3D_LIB_TYPE STREQUAL SHARED AND (CMAKE_CROSSCOMPILING OR IOS))

View File

@ -29,6 +29,7 @@ endif ()
define_source_files (GLOB_CPP_PATTERNS *.cpp ${GRAPHICS_SYS_DIR}/*.cpp GLOB_H_PATTERNS *.h ${GRAPHICS_SYS_DIR}/*.h PARENT_SCOPE)
# Define dependency libs
set (ENGINE_INCLUDE_DIRS_ONLY ${ENGINE_INCLUDE_DIRS_ONLY} ../ThirdParty/SDL/include PARENT_SCOPE)
if (USE_OPENGL AND NOT IOS AND NOT ANDROID AND NOT RASPI)
set (ENGINE_INCLUDE_DIRS_ONLY ${ENGINE_INCLUDE_DIRS_ONLY} ../ThirdParty/GLEW PARENT_SCOPE)
endif ()

View File

@ -1,11 +1,37 @@
#
# Copyright (c) 2008-2013 the Urho3D project.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
prefix=@DEST_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=${prefix}/@DEST_INCLUDE_DIR@
libdir=${exec_prefix}/@DEST_LIBRARY_DIR@
includedir=${prefix}/@DEST_INCLUDE_DIR@
Name: Urho3D
Description: Urho3D is a lightweight, cross-platform rendering and game engine implemented in C++ and released under the MIT license. Greatly inspired by OGRE (http://www.ogre3d.org) and Horde3D (http://www.horde3d.org).
Version: 1.3.0
URL: https://code.google.com/p/urho3d/
Cflags: @URHO3D_COMPILE_DEFINITIONS@ @CMAKE_CXX_FLAGS@ @GLOBAL_INCLUDE_DIRS@ @URHO3D_INCLUDE_DIRS@
Libs: @CMAKE_EXE_LINKER_FLAGS@ @URHO3D_ABS_PATH_LIBS@ -L${libdir} @URHO3D_LIBS@
Cflags: @URHO3D_COMPILE_DEFINITIONS@ @CMAKE_CXX_FLAGS@ @GLOBAL_INCLUDE_DIRS@ @URHO3D_INCLUDE_DIRS@
# Additional Cflags for:
# DEBUG: @CMAKE_CXX_FLAGS_DEBUG@
# RELEASE: @CMAKE_CXX_FLAGS_RELEASE@
# RELWITHDEBINFO: @CMAKE_CXX_FLAGS_RELWITHDEBINFO@