Browse Source

Shed off old construct since our CMake minimum required is 3.10.2 now.

Yao Wei Tjong 姚伟忠 5 years ago
parent
commit
0e4d095cfa

+ 1 - 1
CMake/Modules/FindNetworkAudioSystem.cmake

@@ -31,6 +31,6 @@ find_path (NAS_INCLUDE_DIRS NAMES audio/audiolib.h nas/audiolib.h DOC "NetworkAu
 find_library (NAS_LIBRARIES NAMES audio DOC "NetworkAudioSystem library")
 
 include (FindPackageHandleStandardArgs)
-find_package_handle_standard_args (NAS REQUIRED_VARS NAS_LIBRARIES NAS_INCLUDE_DIRS FAIL_MESSAGE "Could NOT find NetworkAudioSystem development library")
+find_package_handle_standard_args (NetworkAudioSystem REQUIRED_VARS NAS_LIBRARIES NAS_INCLUDE_DIRS FAIL_MESSAGE "Could NOT find NetworkAudioSystem development library")
 
 mark_as_advanced (NAS_INCLUDE_DIRS NAS_LIBRARIES)

+ 2 - 16
CMake/Modules/UrhoCommon.cmake

@@ -1643,10 +1643,8 @@ macro (setup_main_executable)
             endif ()
         endif ()
         setup_executable (${EXE_TYPE} ${ARG_UNPARSED_ARGUMENTS})
-        if (HAS_SHELL_FILE)
-            get_target_property (LOCATION ${TARGET_NAME} LOCATION)
-            get_filename_component (NAME_WE ${LOCATION} NAME_WE)
-            add_make_clean_files ($<TARGET_FILE_DIR:${TARGET_NAME}>/${NAME_WE}.js $<TARGET_FILE_DIR:${TARGET_NAME}>/${NAME_WE}.wasm)
+        if (HAS_SHELL_FILE AND NOT CMAKE_VERSION VERSION_LESS 3.15)
+            add_make_clean_files ($<TARGET_FILE_DIR:${TARGET_NAME}>/$<TARGET_FILE_BASE_NAME:${TARGET_NAME}>.js $<TARGET_FILE_DIR:${TARGET_NAME}>/$<TARGET_FILE_BASE_NAME:${TARGET_NAME}>.wasm)
         endif ()
     endif ()
     # Setup custom resource checker target
@@ -1818,18 +1816,6 @@ macro (_setup_target)
             endif ()
         endforeach ()
     endif ()
-    # Workaround CMake/Xcode generator bug where it always appends '/build' path element to SYMROOT attribute and as such the items in Products are always rendered as red in the Xcode as if they are not yet built
-    if (NOT DEFINED ENV{TRAVIS})
-        if (XCODE AND NOT CMAKE_PROJECT_NAME MATCHES ^Urho3D-ExternalProject-)
-            file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/build)
-            get_target_property (LOCATION ${TARGET_NAME} LOCATION)
-            string (REGEX REPLACE "^.*\\$\\(CONFIGURATION\\)" $(CONFIGURATION) SYMLINK ${LOCATION})
-            get_filename_component (DIRECTORY ${SYMLINK} PATH)
-            add_custom_command (TARGET ${TARGET_NAME} POST_BUILD
-                COMMAND mkdir -p ${DIRECTORY} && ln -sf $<TARGET_FILE:${TARGET_NAME}> ${DIRECTORY}/$<TARGET_FILE_NAME:${TARGET_NAME}>
-                WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/build)
-        endif ()
-    endif ()
 endmacro()
 
 # Macro for setting up a test case

+ 0 - 12
CMakeLists.txt

@@ -22,18 +22,6 @@
 
 # Set CMake minimum version and CMake policy required by UrhoCommon module
 cmake_minimum_required (VERSION 3.10.2)
-if (COMMAND cmake_policy)
-    # Libraries linked via full path no longer produce linker search paths
-    cmake_policy (SET CMP0003 NEW)
-    # INTERFACE_LINK_LIBRARIES defines the link interface
-    cmake_policy (SET CMP0022 NEW)
-    # Disallow use of the LOCATION target property - so we set to OLD as we still need it
-    cmake_policy (SET CMP0026 OLD)
-    # MACOSX_RPATH is enabled by default
-    cmake_policy (SET CMP0042 NEW)
-    # Honor the visibility properties for SHARED target types only
-    cmake_policy (SET CMP0063 OLD)
-endif ()
 
 # Set project name
 project (Urho3D)

+ 0 - 12
Docs/GettingStarted.dox

@@ -604,18 +604,6 @@ In your own project root directory, create a main CMakeLists.txt file and add th
 \code
 # Set CMake minimum version and CMake policy required by UrhoCommon module
 cmake_minimum_required (VERSION 3.10.2)
-if (COMMAND cmake_policy)
-    # Libraries linked via full path no longer produce linker search paths
-    cmake_policy (SET CMP0003 NEW)
-    # INTERFACE_LINK_LIBRARIES defines the link interface
-    cmake_policy (SET CMP0022 NEW)
-    # Disallow use of the LOCATION target property - so we set to OLD as we still need it
-    cmake_policy (SET CMP0026 OLD)
-    # MACOSX_RPATH is enabled by default
-    cmake_policy (SET CMP0042 NEW)
-    # Honor the visibility properties for SHARED target types only
-    cmake_policy (SET CMP0063 OLD)
-endif ()
 
 # Set project name
 project (MyProjectName)

+ 0 - 12
Rakefile

@@ -650,18 +650,6 @@ def scaffolding dir, project = 'Scaffolding', target = 'Main'
   build_script = <<EOF
 # Set CMake minimum version and CMake policy required by UrhoCommon module
 cmake_minimum_required (VERSION 3.10.2)
-if (COMMAND cmake_policy)
-    # Libraries linked via full path no longer produce linker search paths
-    cmake_policy (SET CMP0003 NEW)
-    # INTERFACE_LINK_LIBRARIES defines the link interface
-    cmake_policy (SET CMP0022 NEW)
-    # Disallow use of the LOCATION target property - so we set to OLD as we still need it
-    cmake_policy (SET CMP0026 OLD)
-    # MACOSX_RPATH is enabled by default
-    cmake_policy (SET CMP0042 NEW)
-    # Honor the visibility properties for SHARED target types only
-    cmake_policy (SET CMP0063 OLD)
-endif ()
 
 # Set project name
 project (#{project})

+ 0 - 12
Source/Clang-Tools/CMakeLists.txt

@@ -29,18 +29,6 @@ if (CMAKE_PROJECT_NAME STREQUAL Urho3D)
 else ()
     # Set CMake minimum version and CMake policy required by UrhoCommon module
     cmake_minimum_required (VERSION 3.10.2)
-    if (COMMAND cmake_policy)
-        # Libraries linked via full path no longer produce linker search paths
-        cmake_policy (SET CMP0003 NEW)
-        # INTERFACE_LINK_LIBRARIES defines the link interface
-        cmake_policy (SET CMP0022 NEW)
-        # Disallow use of the LOCATION target property - so we set to OLD as we still need it
-        cmake_policy (SET CMP0026 OLD)
-        # MACOSX_RPATH is enabled by default
-        cmake_policy (SET CMP0042 NEW)
-        # Honor the visibility properties for SHARED target types only
-        cmake_policy (SET CMP0063 OLD)
-    endif ()
 
     # Set project name
     project (Urho3D-ExternalProject-${URHO3D_CLANG_TOOLS})

+ 0 - 0
Source/ThirdParty/Assimp/cmake-modules/FindRT.cmake → Source/ThirdParty/Assimp/cmake-modules/Findrt.cmake


+ 1 - 1
Source/ThirdParty/Assimp/code/CMakeLists.txt

@@ -851,7 +851,7 @@ SOURCE_GROUP( open3dgc FILES ${open3dgc_SRCS})
 # has implementation for different platforms: WIN32, __MACH__ and other ("else" block).
 # Urho3D: Only perform the dependency search on non-MSVC build
 IF (NOT MSVC)
-  FIND_PACKAGE(RT QUIET)
+  FIND_PACKAGE(rt QUIET)
 ENDIF ()
 IF (RT_FOUND OR MSVC)
   SET( ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC 1 )

+ 1 - 17
Source/ThirdParty/LuaJIT/CMakeLists.txt

@@ -25,23 +25,7 @@
 
 if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
     # Set CMake minimum version and CMake policy required by UrhoCommon module
-    if (APPLE)
-        cmake_minimum_required (VERSION 3.10.2)
-    else ()
-        cmake_minimum_required (VERSION 3.10.2)
-    endif ()
-    if (COMMAND cmake_policy)
-        # Libraries linked via full path no longer produce linker search paths
-        cmake_policy (SET CMP0003 NEW)
-        # INTERFACE_LINK_LIBRARIES defines the link interface
-        cmake_policy (SET CMP0022 NEW)
-        # Disallow use of the LOCATION target property - so we set to OLD as we still need it
-        cmake_policy (SET CMP0026 OLD)
-        # MACOSX_RPATH is enabled by default
-        cmake_policy (SET CMP0042 NEW)
-        # Honor the visibility properties for SHARED target types only
-        cmake_policy (SET CMP0063 OLD)
-    endif ()
+    cmake_minimum_required (VERSION 3.10.2)
 
     # Set project name
     project (Urho3D-ExternalProject-LuaJIT-${ARCH})

+ 1 - 17
Source/ThirdParty/LuaJIT/src/host/CMakeLists.txt

@@ -22,23 +22,7 @@
 
 if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
     # Set CMake minimum version and CMake policy required by UrhoCommon module
-    if (APPLE)
-        cmake_minimum_required (VERSION 3.10.2)
-    else ()
-        cmake_minimum_required (VERSION 3.10.2)
-    endif ()
-    if (COMMAND cmake_policy)
-        # Libraries linked via full path no longer produce linker search paths
-        cmake_policy (SET CMP0003 NEW)
-        # INTERFACE_LINK_LIBRARIES defines the link interface
-        cmake_policy (SET CMP0022 NEW)
-        # Disallow use of the LOCATION target property - so we set to OLD as we still need it
-        cmake_policy (SET CMP0026 OLD)
-        # MACOSX_RPATH is enabled by default
-        cmake_policy (SET CMP0042 NEW)
-        # Honor the visibility properties for SHARED target types only
-        cmake_policy (SET CMP0063 OLD)
-    endif ()
+    cmake_minimum_required (VERSION 3.10.2)
 
     # Set project name
     project (Urho3D-ExternalProject-buildvm)

+ 0 - 12
Source/ThirdParty/toluapp/src/bin/CMakeLists.txt

@@ -23,18 +23,6 @@
 if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
     # Set CMake minimum version and CMake policy required by UrhoCommon module
     cmake_minimum_required (VERSION 3.10.2)
-    if (COMMAND cmake_policy)
-        # Libraries linked via full path no longer produce linker search paths
-        cmake_policy (SET CMP0003 NEW)
-        # INTERFACE_LINK_LIBRARIES defines the link interface
-        cmake_policy (SET CMP0022 NEW)
-        # Disallow use of the LOCATION target property - so we set to OLD as we still need it
-        cmake_policy (SET CMP0026 OLD)
-        # MACOSX_RPATH is enabled by default
-        cmake_policy (SET CMP0042 NEW)
-        # Honor the visibility properties for SHARED target types only
-        cmake_policy (SET CMP0063 OLD)
-    endif ()
 
     # Set project name
     project (Urho3D-ExternalProject-tolua++)

+ 0 - 12
Source/Tools/PackageTool/CMakeLists.txt

@@ -23,18 +23,6 @@
 if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
     # Set CMake minimum version and CMake policy required by UrhoCommon module
     cmake_minimum_required (VERSION 3.10.2)
-    if (COMMAND cmake_policy)
-        # Libraries linked via full path no longer produce linker search paths
-        cmake_policy (SET CMP0003 NEW)
-        # INTERFACE_LINK_LIBRARIES defines the link interface
-        cmake_policy (SET CMP0022 NEW)
-        # Disallow use of the LOCATION target property - so we set to OLD as we still need it
-        cmake_policy (SET CMP0026 OLD)
-        # MACOSX_RPATH is enabled by default
-        cmake_policy (SET CMP0042 NEW)
-        # Honor the visibility properties for SHARED target types only
-        cmake_policy (SET CMP0063 OLD)
-    endif ()
 
     # Set project name
     project (Urho3D-ExternalProject-PackageTool)

+ 22 - 57
Source/Urho3D/CMakeLists.txt

@@ -272,43 +272,8 @@ execute_process (COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_B
 file (REMOVE ${CMAKE_CURRENT_BINARY_DIR}/Urho3D.h.new)
 source_group ("Source Files\\Generated" FILES ${CMAKE_CURRENT_BINARY_DIR}/Urho3D.h)
 
-# Define generated object files
-# This is a hack as it relies on internal working of CMake
-if (MSVC AND URHO3D_LIB_TYPE STREQUAL SHARED)   # MSVC linker does not have force_load/whole_archive equivalent
-    foreach (TARGET ${STATIC_LIBRARY_TARGETS})
-        get_target_property (SOURCES ${TARGET} SOURCES)
-        get_target_property (INT_DIR ${TARGET} LOCATION)
-        if (INT_DIR)
-            get_filename_component (INT_DIR ${INT_DIR} PATH)
-            if (CMAKE_GENERATOR MATCHES 2008)
-                string (REPLACE /$(OutDir) /${TARGET}.dir/$(ConfigurationName) INT_DIR ${INT_DIR})
-            elseif (VS)
-                string (REPLACE /$(Configuration) /${TARGET}.dir/$(ConfigurationName) INT_DIR ${INT_DIR})
-            endif ()
-            foreach (SOURCE ${SOURCES})
-                get_filename_component (NAME ${SOURCE} NAME)
-                if (NAME MATCHES \\.c.*$|\\.mm?$|\\.S$|\\.s$)
-                    if (VS)
-                        string (REGEX REPLACE \\.c.*$|\\.mm?$|\\.S$|\\.s$ "" NAME "${NAME}")
-                        list (APPEND OBJ_FILES ${INT_DIR}/${NAME}.obj)
-                    else ()
-                        string (REGEX REPLACE ^.*/ThirdParty/${TARGET}/ "" SOURCE "${SOURCE}")
-                        list (APPEND OBJ_FILES ${INT_DIR}/CMakeFiles/${TARGET}.dir/${SOURCE}.obj)
-                    endif ()
-                elseif (NAME MATCHES \\.o.*$)
-                    list (APPEND OBJ_FILES ${SOURCE})
-                endif ()
-            endforeach ()
-            source_group ("Object Files\\${TARGET}" FILES ${OBJ_FILES})
-            list (APPEND ALL_OBJ_FILES ${OBJ_FILES})
-            unset (OBJ_FILES)
-        endif ()
-    endforeach ()
-    set_source_files_properties (${ALL_OBJ_FILES} PROPERTIES GENERATED TRUE)
-endif ()
-
 # Aggregate all source files
-list (APPEND SOURCE_FILES ${GEN_CPP_FILES} ${LUA_GEN_CPP_FILES} ${ALL_OBJ_FILES} librevision.h Urho3D.h ${SYMBOLIC_SOURCES})
+list (APPEND SOURCE_FILES ${GEN_CPP_FILES} ${LUA_GEN_CPP_FILES} librevision.h Urho3D.h ${SYMBOLIC_SOURCES})
 
 # Define dependency libs
 # Add include directories to find the precompiled header, export header, and installed headers from third-party libs
@@ -394,40 +359,40 @@ if (WIN32 AND URHO3D_LIB_TYPE STREQUAL SHARED)
     set (URHO3D_DLL_INSTALLED TRUE)
 endif ()
 
-# Setup dependency frameworks and libraries
+# TODO: This seems out of place
 if (MINGW)
     set (CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES_INIT} -lwinmm")
     set (CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES_INIT} -lwinmm")
-endif ()
-if (APPLE)
-    set (FORCE_LOAD -force_load)
-elseif (NOT MSVC)
-    set_property (TARGET ${TARGET_NAME} APPEND PROPERTY LINK_LIBRARIES -Wl,--whole-archive)
-    if (WIN32 AND URHO3D_LIB_TYPE STREQUAL SHARED)
+    if (URHO3D_LIB_TYPE STREQUAL SHARED)
         set_target_properties (${TARGET_NAME} PROPERTIES PREFIX "")
     endif ()
 endif ()
+
+# Setup dependency libraries to be linked or archived as a whole inside Urho3D library for SHARED or STATIC lib type, respectively
+if (APPLE)
+    set (WHOLE_ARCHIVE -force_load)
+elseif (MSVC)
+    set (WHOLE_ARCHIVE /WHOLEARCHIVE)   # Require VS 2015 Update 2 onward
+else ()
+    set (WHOLE_ARCHIVE -Wl,--whole-archive)
+endif ()
+set_property (TARGET ${TARGET_NAME} APPEND PROPERTY LINK_LIBRARIES ${WHOLE_ARCHIVE})
 foreach (TARGET ${STATIC_LIBRARY_TARGETS})
-    get_target_property (ARCHIVE ${TARGET} LOCATION)
-    if (ARCHIVE)
-        if (NOT MSVC)
-            set_property (TARGET ${TARGET_NAME} APPEND PROPERTY LINK_LIBRARIES ${FORCE_LOAD} ${ARCHIVE})    # Only works in Apple (Xcode and Makefile) and GCC while building shared library
-        endif ()
-        if (MSVC_VERSION VERSION_EQUAL 1500)
-            if (ARCHIVE MATCHES " ")
-                message (FATAL_ERROR "CMake/VS2008 generator does not support spaces in the source and/or build tree path")
+    set (ARCHIVE $<TARGET_FILE:${TARGET}>)
+    if (NOT ${TARGET} MATCHES boost|rapidjson|STB)    # Exlucde header-only "fake" static lib targets
+        set_property (TARGET ${TARGET_NAME} APPEND PROPERTY LINK_LIBRARIES ${ARCHIVE})    # Should work for all platforms while building shared library
+        if (URHO3D_LIB_TYPE STREQUAL STATIC)
+            if (XCODE OR MSVC)  # Only works in Xcode and MSVC while building static library
+                set_property (TARGET ${TARGET_NAME} APPEND_STRING PROPERTY STATIC_LIBRARY_FLAGS " \"${ARCHIVE}\"")
+            else ()
+                list (APPEND ARCHIVES ${ARCHIVE})   # Accumulate the target locations for archiving later
             endif ()
-            set_property (TARGET ${TARGET_NAME} APPEND_STRING PROPERTY STATIC_LIBRARY_FLAGS " ${ARCHIVE}")  # Fallback for VS2008
-        elseif (XCODE OR MSVC)
-            set_property (TARGET ${TARGET_NAME} APPEND_STRING PROPERTY STATIC_LIBRARY_FLAGS " \"${ARCHIVE}\"")  # Only works in Apple (Xcode only) and MSVC while building static library
-        else ()
-            list (APPEND ARCHIVES ${ARCHIVE})
         endif ()
     endif ()
 endforeach ()
 if (NOT XCODE AND NOT MSVC)
     if (NOT APPLE)
-        set_property (TARGET ${TARGET_NAME} APPEND PROPERTY LINK_LIBRARIES -Wl,--no-whole-archive)
+        set_property (TARGET ${TARGET_NAME} APPEND PROPERTY LINK_LIBRARIES -Wl,--no-whole-archive)  # GCC/Clang-specific to pair up with whole-archive linker option
     endif ()
     if (URHO3D_LIB_TYPE STREQUAL STATIC)
         if (APPLE)

+ 0 - 12
android/launcher-app/CMakeLists.txt

@@ -22,18 +22,6 @@
 
 # Set CMake minimum version and CMake policy required by UrhoCommon module
 cmake_minimum_required (VERSION 3.10.2)
-if (COMMAND cmake_policy)
-    # Libraries linked via full path no longer produce linker search paths
-    cmake_policy (SET CMP0003 NEW)
-    # INTERFACE_LINK_LIBRARIES defines the link interface
-    cmake_policy (SET CMP0022 NEW)
-    # Disallow use of the LOCATION target property - so we set to OLD as we still need it
-    cmake_policy (SET CMP0026 OLD)
-    # MACOSX_RPATH is enabled by default
-    cmake_policy (SET CMP0042 NEW)
-    # Honor the visibility properties for SHARED target types only
-    cmake_policy (SET CMP0063 OLD)
-endif ()
 
 # Set project name
 project (Urho3D-Launcher)