diff --git a/.gitignore b/.gitignore index f0ac01816d2..c2644add11a 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ CMakeScripts Makefile cmake_install.cmake install_manifest*.txt +.cmake/* # Compiled Object files diff --git a/CMakeLists.txt b/CMakeLists.txt index 21d2c05d423..4abbc86d3aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,23 +13,9 @@ SET(OPENSCENEGRAPH_RELEASE_CANDIDATE 0) set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE) set_property(GLOBAL PROPERTY USE_FOLDERS ON) -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5 FATAL_ERROR) if(COMMAND cmake_policy) - # Works around warnings libraries linked against that don't - # have absolute paths (e.g. -lpthreads) - cmake_policy(SET CMP0003 NEW) - - # Works around warnings about escaped quotes in ADD_DEFINITIONS - # statements. - cmake_policy(SET CMP0005 NEW) - - # tell CMake to prefer CMake's own CMake modules when available - # only available from cmake-2.8.4 - if("${CMAKE_VERSION}" VERSION_GREATER 2.8.3) - cmake_policy(SET CMP0017 NEW) - endif() - # INTERPROCEDURAL_OPTIMIZATION is enforced when enabled. # Allows passing -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON cmake_policy(SET CMP0069 NEW) @@ -902,22 +888,8 @@ IF(DEFINED LIB_POSTFIX) # Use LIB_POSTFIX if defined SET(OSG_INSTALL_LIBDIR lib${LIB_POSTFIX}) ELSE() - IF(CMAKE_VERSION VERSION_LESS "2.8.5") - IF(UNIX AND NOT WIN32 AND NOT APPLE) - IF(CMAKE_SIZEOF_VOID_P MATCHES "8") - SET(LIB_POSTFIX "64" CACHE STRING "suffix for 32/64 dir placement") - MARK_AS_ADVANCED(LIB_POSTFIX) - ENDIF() - ENDIF() - IF(NOT DEFINED LIB_POSTFIX) - SET(LIB_POSTFIX "") - ENDIF() - SET(OSG_INSTALL_LIBDIR lib${LIB_POSTFIX}) - ELSE() - # Use the GNU standard installation directories for CMake >= 2.8.5 - INCLUDE(GNUInstallDirs) - SET(OSG_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}) - ENDIF() + INCLUDE(GNUInstallDirs) + SET(OSG_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}) ENDIF() IF(NOT DEFINED LIB_POSTFIX) SET(LIB_POSTFIX "") @@ -952,20 +924,17 @@ ELSE(WIN32) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR}) ENDIF(WIN32) -# Testing CMAKE_VERSION is possible in >= 2.6.4 only -BUILDER_VERSION_GREATER(2 8 0) -IF(VALID_BUILDER_VERSION) # If CMake >= 2.8.1 - FOREACH(CONF ${CMAKE_CONFIGURATION_TYPES}) # For each configuration (Debug, Release, MinSizeRel... and/or anything the user chooses) - STRING(TOUPPER "${CONF}" CONF) # Go uppercase (DEBUG, RELEASE...) - SET("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}") - SET("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_BINDIR}") - IF(WIN32) - SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_BINDIR}") - ELSE() - SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}") - ENDIF() - ENDFOREACH() -ENDIF(VALID_BUILDER_VERSION) + +FOREACH(CONF ${CMAKE_CONFIGURATION_TYPES}) # For each configuration (Debug, Release, MinSizeRel... and/or anything the user chooses) + STRING(TOUPPER "${CONF}" CONF) # Go uppercase (DEBUG, RELEASE...) + SET("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}") + SET("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_BINDIR}") + IF(WIN32) + SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_BINDIR}") + ELSE() + SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}") + ENDIF() +ENDFOREACH() #SET(INSTALL_BINDIR OpenSceneGraph/bin) #SET(INSTALL_INCDIR OpenSceneGraph/include) @@ -1036,7 +1005,7 @@ ELSEIF(MSVC) #C4706 assignment within conditional expression #C4589: Constructor of abstract class 'osgGA::CameraManipulator' ignores initializer for virtual base class 'osg::Object' SET(OSG_AGGRESSIVE_WARNING_FLAGS /W4 /wd4589 /wd4706 /wd4127 /wd4100) -ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") SET(OSG_AGGRESSIVE_WARNING_FLAGS -Wall -Wparentheses -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -Wno-overloaded-virtual) # CMake lacks an elseif, so other non-gcc, non-VS compilers need diff --git a/CMakeModules/FindFBX.cmake b/CMakeModules/FindFBX.cmake index 6ffee2ceb6b..d45b6e849aa 100644 --- a/CMakeModules/FindFBX.cmake +++ b/CMakeModules/FindFBX.cmake @@ -9,7 +9,7 @@ # correspond to the ./configure --prefix=$FBX_DIR IF(APPLE) - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") # using regular Clang or AppleClang SET(FBX_LIBDIR "clang") else() diff --git a/CMakeModules/OsgCPack.cmake b/CMakeModules/OsgCPack.cmake index 8fcb37680eb..97f76a346a6 100644 --- a/CMakeModules/OsgCPack.cmake +++ b/CMakeModules/OsgCPack.cmake @@ -60,7 +60,7 @@ SET(CPACK_SOURCE_GENERATOR "TGZ") # for ms visual studio we use it's internally defined variable to get the configuration (debug,release, ...) IF(MSVC_IDE) SET(OSG_CPACK_CONFIGURATION "$(OutDir)") - SET(PACKAGE_TARGET_PREFIX "Package ") + SET(PACKAGE_TARGET_PREFIX "Package_") ELSE() # on un*x an empty CMAKE_BUILD_TYPE means release IF(CMAKE_BUILD_TYPE) diff --git a/CMakeModules/OsgMacroUtils.cmake b/CMakeModules/OsgMacroUtils.cmake index cafd8725ba3..e9f1d0c3dd9 100644 --- a/CMakeModules/OsgMacroUtils.cmake +++ b/CMakeModules/OsgMacroUtils.cmake @@ -9,32 +9,6 @@ # the content of this library for linking when in debugging ####################################################################################################### -# VALID_BUILDER_VERSION: used for replacing CMAKE_VERSION (available in v2.6.3 RC9) and VERSION_GREATER/VERSION_LESS (available in 2.6.2 RC4). -# This can be replaced by "IF(${CMAKE_VERSION} VERSION_LESS "x.y.z")" from 2.6.4. -SET(VALID_BUILDER_VERSION OFF) -MACRO(BUILDER_VERSION_GREATER MAJOR_VER MINOR_VER PATCH_VER) - SET(VALID_BUILDER_VERSION OFF) - IF(CMAKE_MAJOR_VERSION GREATER ${MAJOR_VER}) - SET(VALID_BUILDER_VERSION ON) - ELSEIF(CMAKE_MAJOR_VERSION EQUAL ${MAJOR_VER}) - IF(CMAKE_MINOR_VERSION GREATER ${MINOR_VER}) - SET(VALID_BUILDER_VERSION ON) - ELSEIF(CMAKE_MINOR_VERSION EQUAL ${MINOR_VER}) - IF(CMAKE_PATCH_VERSION GREATER ${PATCH_VER}) - SET(VALID_BUILDER_VERSION ON) - ENDIF(CMAKE_PATCH_VERSION GREATER ${PATCH_VER}) - ENDIF() - ENDIF() -ENDMACRO(BUILDER_VERSION_GREATER MAJOR_VER MINOR_VER PATCH_VER) - - -# CMAKE_VERSION_TEST: Define whether "IF(${CMAKE_VERSION} VERSION_LESS "x.y.z")" can be used or not. -BUILDER_VERSION_GREATER(2 8 0) -SET(CMAKE_VERSION_TEST ${VALID_BUILDER_VERSION}) # >= 2.8.0 - -SET(VALID_BUILDER_VERSION OFF) - - MACRO(LINK_WITH_VARIABLES TRGTNAME) FOREACH(varname ${ARGN}) IF(${varname}_DEBUG) @@ -50,22 +24,7 @@ MACRO(LINK_WITH_VARIABLES TRGTNAME) ENDMACRO(LINK_WITH_VARIABLES TRGTNAME) MACRO(LINK_INTERNAL TRGTNAME) - IF(NOT CMAKE24) - TARGET_LINK_LIBRARIES(${TRGTNAME} ${ARGN}) - ELSE(NOT CMAKE24) - FOREACH(LINKLIB ${ARGN}) - IF(MSVC AND OSG_MSVC_VERSIONED_DLL) - #when using versioned names, the .dll name differ from .lib name, there is a problem with that: - #CMake 2.4.7, at least seem to use PREFIX instead of IMPORT_PREFIX for computing linkage info to use into projects, - # so we full path name to specify linkage, this prevent automatic inferencing of dependencies, so we add explicit depemdencies - #to library targets used - TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_RELEASE_POSTFIX}.lib" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}.lib") - ADD_DEPENDENCIES(${TRGTNAME} ${LINKLIB}) - ELSE(MSVC AND OSG_MSVC_VERSIONED_DLL) - TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${LINKLIB}${CMAKE_RELEASE_POSTFIX}" debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}") - ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL) - ENDFOREACH(LINKLIB) - ENDIF(NOT CMAKE24) + TARGET_LINK_LIBRARIES(${TRGTNAME} ${ARGN}) ENDMACRO(LINK_INTERNAL TRGTNAME) MACRO(LINK_EXTERNAL TRGTNAME) @@ -161,39 +120,29 @@ ENDMACRO(SETUP_LINK_LIBRARIES) # Sets the output directory property for CMake >= 2.6.0, giving an output path RELATIVE to default one MACRO(SET_OUTPUT_DIR_PROPERTY_260 TARGET_TARGETNAME RELATIVE_OUTDIR) - BUILDER_VERSION_GREATER(2 8 0) - IF(NOT VALID_BUILDER_VERSION) - # If CMake <= 2.8.0 (Testing CMAKE_VERSION is possible in >= 2.6.4) - IF(MSVC_IDE) - # Using the "prefix" hack - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../${RELATIVE_OUTDIR}/") - ELSE(MSVC_IDE) - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${RELATIVE_OUTDIR}/") - ENDIF(MSVC_IDE) - ELSE(NOT VALID_BUILDER_VERSION) - # Using the output directory properties - - # Global properties (All generators but VS & Xcode) - FILE(TO_CMAKE_PATH TMPVAR "CMAKE_ARCHIVE_OUTPUT_DIRECTORY/${RELATIVE_OUTDIR}") - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${TMPVAR}") - FILE(TO_CMAKE_PATH TMPVAR "CMAKE_RUNTIME_OUTPUT_DIRECTORY/${RELATIVE_OUTDIR}") - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TMPVAR}") - FILE(TO_CMAKE_PATH TMPVAR "CMAKE_LIBRARY_OUTPUT_DIRECTORY/${RELATIVE_OUTDIR}") - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${TMPVAR}") - - # Per-configuration property (VS, Xcode) - FOREACH(CONF ${CMAKE_CONFIGURATION_TYPES}) # For each configuration (Debug, Release, MinSizeRel... and/or anything the user chooses) - STRING(TOUPPER "${CONF}" CONF) # Go uppercase (DEBUG, RELEASE...) - - # We use "FILE(TO_CMAKE_PATH", to create nice looking paths - FILE(TO_CMAKE_PATH "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONF}}/${RELATIVE_OUTDIR}" TMPVAR) - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES "ARCHIVE_OUTPUT_DIRECTORY_${CONF}" "${TMPVAR}") - FILE(TO_CMAKE_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONF}}/${RELATIVE_OUTDIR}" TMPVAR) - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES "RUNTIME_OUTPUT_DIRECTORY_${CONF}" "${TMPVAR}") - FILE(TO_CMAKE_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}}/${RELATIVE_OUTDIR}" TMPVAR) - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES "LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${TMPVAR}") - ENDFOREACH(CONF ${CMAKE_CONFIGURATION_TYPES}) - ENDIF(NOT VALID_BUILDER_VERSION) + + # Using the output directory properties + + # Global properties (All generators but VS & Xcode) + FILE(TO_CMAKE_PATH TMPVAR "CMAKE_ARCHIVE_OUTPUT_DIRECTORY/${RELATIVE_OUTDIR}") + SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${TMPVAR}") + FILE(TO_CMAKE_PATH TMPVAR "CMAKE_RUNTIME_OUTPUT_DIRECTORY/${RELATIVE_OUTDIR}") + SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TMPVAR}") + FILE(TO_CMAKE_PATH TMPVAR "CMAKE_LIBRARY_OUTPUT_DIRECTORY/${RELATIVE_OUTDIR}") + SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${TMPVAR}") + + # Per-configuration property (VS, Xcode) + FOREACH(CONF ${CMAKE_CONFIGURATION_TYPES}) # For each configuration (Debug, Release, MinSizeRel... and/or anything the user chooses) + STRING(TOUPPER "${CONF}" CONF) # Go uppercase (DEBUG, RELEASE...) + + # We use "FILE(TO_CMAKE_PATH", to create nice looking paths + FILE(TO_CMAKE_PATH "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONF}}/${RELATIVE_OUTDIR}" TMPVAR) + SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES "ARCHIVE_OUTPUT_DIRECTORY_${CONF}" "${TMPVAR}") + FILE(TO_CMAKE_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONF}}/${RELATIVE_OUTDIR}" TMPVAR) + SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES "RUNTIME_OUTPUT_DIRECTORY_${CONF}" "${TMPVAR}") + FILE(TO_CMAKE_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}}/${RELATIVE_OUTDIR}" TMPVAR) + SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES "LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${TMPVAR}") + ENDFOREACH(CONF ${CMAKE_CONFIGURATION_TYPES}) ENDMACRO(SET_OUTPUT_DIR_PROPERTY_260 TARGET_TARGETNAME RELATIVE_OUTDIR) @@ -302,34 +251,7 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME) ENDIF(DYNAMIC_OPENSCENEGRAPH) IF(MSVC) - IF(NOT CMAKE24) - SET_OUTPUT_DIR_PROPERTY_260(${TARGET_TARGETNAME} "${OSG_PLUGINS}") # Sets the ouput to be /osgPlugin-X.X.X ; also ensures the /Debug /Release are removed - ELSE(NOT CMAKE24) - - IF(OSG_MSVC_VERSIONED_DLL) - - #this is a hack... the build place is set to lib/ by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR - #the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property - #because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there, - #it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented - #changing bin to something else breaks this hack - #the dll are placed in bin/${OSG_PLUGINS} - - IF(NOT MSVC_IDE) - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../bin/${OSG_PLUGINS}/") - ELSE(NOT MSVC_IDE) - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../../bin/${OSG_PLUGINS}/" IMPORT_PREFIX "../") - ENDIF(NOT MSVC_IDE) - - ELSE(OSG_MSVC_VERSIONED_DLL) - - #in standard mode (unversioned) the .lib and .dll are placed in lib//${OSG_PLUGINS}. - #here the PREFIX property has been used, the same result would be accomplidhe by prepending ${OSG_PLUGINS}/ to OUTPUT_NAME target property - - SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${OSG_PLUGINS}/") - ENDIF(OSG_MSVC_VERSIONED_DLL) - - ENDIF(NOT CMAKE24) + SET_OUTPUT_DIR_PROPERTY_260(${TARGET_TARGETNAME} "${OSG_PLUGINS}") # Sets the ouput to be /osgPlugin-X.X.X ; also ensures the /Debug /Release are removed ENDIF(MSVC) SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}") @@ -433,6 +355,14 @@ MACRO(SETUP_EXE IS_COMMANDLINE_APP) ENDIF() ENDIF() + IF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND DYNAMIC_OPENSCENEGRAPH) + # templated types used in OSG plugins and applications need to get the same type ID + # based on investigation for https://gitlab.com/OpenMW/openmw/-/issues/8039 by the OpenMW team, this is believed to only be necessary for Clang on Linux + # i.e. not for GCC anywhere, MSVC on Windows or for AppleClang on MacOS + # it's possible that this is really required by the C++ spec for all platforms and we're just getting away with it everywhere else + SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES ENABLE_EXPORTS ON) + ENDIF() + SETUP_LINK_LIBRARIES() ENDMACRO(SETUP_EXE) @@ -457,7 +387,7 @@ MACRO(SETUP_APPLICATION APPLICATION_NAME) ELSE(APPLE) INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin COMPONENT openscenegraph ) IF(MSVC) - INSTALL(FILES $ DESTINATION bin COMPONENT openscenegraph) + INSTALL(FILES $ DESTINATION bin COMPONENT openscenegraph) ENDIF(MSVC) ENDIF(APPLE) @@ -489,7 +419,7 @@ MACRO(SETUP_EXAMPLE EXAMPLE_NAME) ELSE(APPLE) INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin COMPONENT openscenegraph-examples ) IF(MSVC) - INSTALL(FILES $ DESTINATION share/OpenSceneGraph/bin COMPONENT openscenegraph-examples) + INSTALL(FILES $ DESTINATION share/OpenSceneGraph/bin COMPONENT openscenegraph-examples) ENDIF(MSVC) ENDIF(APPLE) @@ -527,38 +457,9 @@ MACRO(HANDLE_MSVC_DLL) SET_OUTPUT_DIR_PROPERTY_260(${LIB_NAME} "") # Ensure the /Debug /Release are removed IF(NOT MSVC_IDE) - IF (NOT CMAKE24) - BUILDER_VERSION_GREATER(2 8 0) - IF(NOT VALID_BUILDER_VERSION) - # If CMake < 2.8.1 - SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../bin/${LIB_PREFIX}${LIB_SOVERSION}-" IMPORT_PREFIX "../") - ELSE(NOT VALID_BUILDER_VERSION) - SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "${LIB_PREFIX}${LIB_SOVERSION}-") - ENDIF(NOT VALID_BUILDER_VERSION) - ELSE (NOT CMAKE24) - SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../bin/${LIB_PREFIX}${LIB_SOVERSION}-" IMPORT_PREFIX "../") - SET(NEW_LIB_NAME "${OUTPUT_BINDIR}/${LIB_PREFIX}${LIB_SOVERSION}-${LIB_NAME}") - ADD_CUSTOM_COMMAND( - TARGET ${LIB_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${NEW_LIB_NAME}.lib" "${OUTPUT_LIBDIR}/${LIB_NAME}.lib" - COMMAND ${CMAKE_COMMAND} -E copy "${NEW_LIB_NAME}.exp" "${OUTPUT_LIBDIR}/${LIB_NAME}.exp" - COMMAND ${CMAKE_COMMAND} -E remove "${NEW_LIB_NAME}.lib" - COMMAND ${CMAKE_COMMAND} -E remove "${NEW_LIB_NAME}.exp" - ) - ENDIF (NOT CMAKE24) + SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "${LIB_PREFIX}${LIB_SOVERSION}-") ELSE(NOT MSVC_IDE) - IF (NOT CMAKE24) - BUILDER_VERSION_GREATER(2 8 0) - IF(NOT VALID_BUILDER_VERSION) - # If CMake < 2.8.1 - SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/${LIB_PREFIX}${LIB_SOVERSION}-" IMPORT_PREFIX "../") - ELSE(NOT VALID_BUILDER_VERSION) - SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "${LIB_PREFIX}${LIB_SOVERSION}-") - ENDIF(NOT VALID_BUILDER_VERSION) - ELSE (NOT CMAKE24) - SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/${LIB_PREFIX}${LIB_SOVERSION}-" IMPORT_PREFIX "../") - ENDIF (NOT CMAKE24) + SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "${LIB_PREFIX}${LIB_SOVERSION}-") ENDIF(NOT MSVC_IDE) # SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/osg${OPENSCENEGRAPH_SOVERSION}-") diff --git a/CMakeModules/UtilityMacros.cmake b/CMakeModules/UtilityMacros.cmake index 63baf17bf8c..544735bcccc 100644 --- a/CMakeModules/UtilityMacros.cmake +++ b/CMakeModules/UtilityMacros.cmake @@ -101,23 +101,6 @@ MACRO(TARGET_LOCATIONS_SET_FILE FILE) FILE(WRITE ${ACCUM_FILE_TARGETS} "") ENDMACRO() -#--------------------------------------------------- -# Macro: TARGET_LOCATIONS_ACCUM TARGET_NAME -# -#--------------------------------------------------- - -MACRO(TARGET_LOCATIONS_ACCUM TARGET_NAME) - IF(ACCUM_FILE_TARGETS) - IF(EXISTS ${ACCUM_FILE_TARGETS}) - GET_TARGET_PROPERTY(_FILE_LOCATION ${TARGET_NAME} LOCATION) - FILE(APPEND ${ACCUM_FILE_TARGETS} "${_FILE_LOCATION};") - #SET(_TARGETS_LIST ${_TARGETS_LIST} "${_FILE_LOCATION}" CACHE INTERNAL "lista dll") - #MESSAGE("adding target -->${TARGET_NAME}<-- file -->${_FILE_LOCATION}<-- to list -->${_TARGETS_LIST}<--") - #SET(ACCUM_FILE_TARGETS ${ACCUM_FILE_TARGETS} ${_FILE_LOCATION}) - ENDIF() - ENDIF() -ENDMACRO() - #--------------------------------------------------- # Macro: TARGET_LOCATIONS_GET_LIST _VAR # diff --git a/PlatformSpecifics/Android/android.toolchain.cmake b/PlatformSpecifics/Android/android.toolchain.cmake index fc349162fb8..2289010d117 100644 --- a/PlatformSpecifics/Android/android.toolchain.cmake +++ b/PlatformSpecifics/Android/android.toolchain.cmake @@ -210,7 +210,7 @@ # Modified by Lasse Oorni and Yao Wei Tjong for Urho3D -cmake_minimum_required( VERSION 2.6.3 ) +cmake_minimum_required( VERSION 3.5 ) # Urho3D: on Windows Cygwin-based NDK tools may fail in the linking phase with too long command line. Turn on response files to avoid this if( CMAKE_HOST_WIN32 ) @@ -234,11 +234,7 @@ if( _CMAKE_IN_TRY_COMPILE ) endif() # this one is important -if( CMAKE_VERSION VERSION_GREATER "3.0.99" ) - set( CMAKE_SYSTEM_NAME Android ) -else() - set( CMAKE_SYSTEM_NAME Linux ) -endif() +set( CMAKE_SYSTEM_NAME Android ) # this one not so much set( CMAKE_SYSTEM_VERSION 1 ) @@ -854,20 +850,16 @@ else() unset( __realApiLevel ) endif() set( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE ) - if( CMAKE_VERSION VERSION_GREATER "2.8" ) - list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS ) - set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} ) - endif() + list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS ) + set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} ) endif() unset( __levelIdx ) # remember target ABI set( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE ) -if( CMAKE_VERSION VERSION_GREATER "2.8" ) - list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME} ) - set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME}} ) -endif() +list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME} ) +set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME}} ) # runtime choice (STL, rtti, exceptions) @@ -1162,9 +1154,7 @@ if( NOT CMAKE_C_COMPILER ) endif() set( _CMAKE_TOOLCHAIN_PREFIX "${ANDROID_TOOLCHAIN_MACHINE_NAME}-" ) -if( CMAKE_VERSION VERSION_LESS 2.8.5 ) - set( CMAKE_ASM_COMPILER_ARG1 "-c" ) -endif() + if( APPLE ) find_program( CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool ) if( NOT CMAKE_INSTALL_NAME_TOOL ) diff --git a/examples/osgCMakeExample/CMakeLists.txt b/examples/osgCMakeExample/CMakeLists.txt index cd843299add..605f12329f2 100644 --- a/examples/osgCMakeExample/CMakeLists.txt +++ b/examples/osgCMakeExample/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.5) SET(PROJECT_NAME osgCMakeExample) @@ -22,3 +22,11 @@ LINK_DIRECTORIES(${OSG_LIB_DIR}) ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${OSG_LIBRARIES} ${OSGVIEWER_LIBRARIES} ${OSGUTIL_LIBRARIES} ${OSGDB_LIBRARIES} ${OSGGA_LIBRARIES} ${OPENTHREADS_LIBRARIES}) + +IF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # templated types used in OSG plugins and applications need to get the same type ID + # based on investigation for https://gitlab.com/OpenMW/openmw/-/issues/8039 by the OpenMW team, this is believed to only be necessary for Clang on Linux + # i.e. not for GCC anywhere, MSVC on Windows or for AppleClang on MacOS + # it's possible that this is really required by the C++ spec for all platforms and we're just getting away with it everywhere else + SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES ENABLE_EXPORTS ON) +ENDIF() diff --git a/examples/osgemscripten/CMakeLists.txt b/examples/osgemscripten/CMakeLists.txt index b2bc9875a5a..10c4daf687e 100644 --- a/examples/osgemscripten/CMakeLists.txt +++ b/examples/osgemscripten/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5 FATAL_ERROR) # Path to OpenSceneGraph SET(OSG_DIR "${CMAKE_SOURCE_DIR}/../..") diff --git a/src/osgPlugins/cfg/CMakeLists.txt b/src/osgPlugins/cfg/CMakeLists.txt index 4f7062ba995..83597a3cf9d 100644 --- a/src/osgPlugins/cfg/CMakeLists.txt +++ b/src/osgPlugins/cfg/CMakeLists.txt @@ -19,7 +19,7 @@ SET(TARGET_H # lex/yacc generated files use register that causes warnings with CLang under OSX so disable this warnings. -IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") +IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register") ENDIF() diff --git a/src/osgPlugins/dae/CMakeLists.txt b/src/osgPlugins/dae/CMakeLists.txt index 7eadfc2f38e..539b0e5071b 100644 --- a/src/osgPlugins/dae/CMakeLists.txt +++ b/src/osgPlugins/dae/CMakeLists.txt @@ -9,7 +9,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX) STRING(REGEX REPLACE "-Wextra" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") ENDIF() -IF(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") +IF(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") ENDIF() diff --git a/src/osgPlugins/exr/CMakeLists.txt b/src/osgPlugins/exr/CMakeLists.txt index 6191ed18fca..e6b67e08bdf 100644 --- a/src/osgPlugins/exr/CMakeLists.txt +++ b/src/osgPlugins/exr/CMakeLists.txt @@ -5,7 +5,7 @@ SET(TARGET_SRC ReaderWriterEXR.cpp ) SET(TARGET_LIBRARIES_VARS ${OPENEXR_LIBRARIES_VARS} ${ILMBASE_LIBRARIES_VARS} ZLIB_LIBRARIES) -IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") REMOVE_CXX_FLAG(-Wshadow) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") ENDIF() diff --git a/src/osgPlugins/fbx/CMakeLists.txt b/src/osgPlugins/fbx/CMakeLists.txt index 2dc67b13598..72ab22378b7 100644 --- a/src/osgPlugins/fbx/CMakeLists.txt +++ b/src/osgPlugins/fbx/CMakeLists.txt @@ -24,7 +24,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_CXX_FLAGS "-w") -ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") REMOVE_CXX_FLAG(-pedantic) REMOVE_CXX_FLAG(-Wall) diff --git a/src/osgPlugins/ffmpeg/CMakeLists.txt b/src/osgPlugins/ffmpeg/CMakeLists.txt index 6109f916402..a8cb15989ca 100644 --- a/src/osgPlugins/ffmpeg/CMakeLists.txt +++ b/src/osgPlugins/ffmpeg/CMakeLists.txt @@ -61,7 +61,7 @@ SET(TARGET_H MessageQueue.hpp ) -IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") ENDIF() diff --git a/src/osgPlugins/gdal/CMakeLists.txt b/src/osgPlugins/gdal/CMakeLists.txt index f1b67070178..74baa86dd0a 100644 --- a/src/osgPlugins/gdal/CMakeLists.txt +++ b/src/osgPlugins/gdal/CMakeLists.txt @@ -12,7 +12,7 @@ SET(TARGET_H SET(TARGET_LIBRARIES_VARS GDAL_LIBRARY ) SET(TARGET_ADDED_LIBRARIES osgTerrain ) -IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") REMOVE_CXX_FLAG(-Wunused-result) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result") diff --git a/src/osgPlugins/gstreamer/CMakeLists.txt b/src/osgPlugins/gstreamer/CMakeLists.txt index 53c6f271c7a..71a92a956d6 100644 --- a/src/osgPlugins/gstreamer/CMakeLists.txt +++ b/src/osgPlugins/gstreamer/CMakeLists.txt @@ -21,7 +21,7 @@ SET(TARGET_H ) -IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") REMOVE_CXX_FLAG(-pedantic) diff --git a/src/osgPlugins/pdf/CMakeLists.txt b/src/osgPlugins/pdf/CMakeLists.txt index 7957506540c..f6d6ae47c9e 100644 --- a/src/osgPlugins/pdf/CMakeLists.txt +++ b/src/osgPlugins/pdf/CMakeLists.txt @@ -1,6 +1,6 @@ SET(TARGET_SRC ReaderWriterPDF.cpp ) -IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") REMOVE_CXX_FLAG(-pedantic) ENDIF() diff --git a/src/osgPlugins/svg/CMakeLists.txt b/src/osgPlugins/svg/CMakeLists.txt index 1d7b5265d28..19328a5ed82 100644 --- a/src/osgPlugins/svg/CMakeLists.txt +++ b/src/osgPlugins/svg/CMakeLists.txt @@ -4,7 +4,7 @@ LINK_LIBRARIES(${RSVG_LIBRARIES} ${CAIRO_LIBRARIES}) SET(TARGET_SRC ReaderWriterSVG.cpp ) -IF(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") +IF(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") # Remove -pedantic flag as it barfs on ffmoeg headers STRING(REGEX REPLACE "-pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") ENDIF() diff --git a/src/osgPlugins/zip/CMakeLists.txt b/src/osgPlugins/zip/CMakeLists.txt index e805b418159..764456528b3 100644 --- a/src/osgPlugins/zip/CMakeLists.txt +++ b/src/osgPlugins/zip/CMakeLists.txt @@ -11,7 +11,7 @@ SET(TARGET_H ADD_DEFINITIONS(-DZIP_STD) -IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-implicit-fallthrough") ENDIF()