diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d36d8624d..3d948ac50f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,12 @@ -# We require 2.8.4 because earlier releases had a bug -# with invalid HEADER_FILE_ONLY behavior in MSVC 2010. -cmake_minimum_required(VERSION 2.8.4) +# We require 2.8.12+ for three reasons: +# 1) CMake 3 is so common these days that it's really not a burden on the user +# to expect them to have it. +# 2) As of this writing, this is the oldest version included in a supported +# release of Ubuntu. Older versions are actually somewhat difficult to track +# down, so we don't test against them. +# 3) CMake's INTERFACE_INCLUDE_DIRECTORIES feature, which we rely on +# extensively, finally became stable in this release. +cmake_minimum_required(VERSION 2.8.12) set(CMAKE_DISABLE_SOURCE_CHANGES ON) # Must go before project() below set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) # Must go before project() below project(Panda3D) @@ -25,6 +31,10 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/macros/") +# Set certain CMake flags we expect +set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + # Include global modules needed for configure scripts include(PackageConfig) # Defines package_option AND target_use_packages @@ -34,7 +44,6 @@ include(dtool/Package.cmake) include(dtool/Config.cmake) # Include global modules -include(AutoInclude) # Implements automatic include_directories finding include(AddBisonTarget) # Defines add_bison_target function include(AddFlexTarget) # Defines add_flex_target function include(CompositeSources) # Defines composite_sources function diff --git a/cmake/macros/Interrogate.cmake b/cmake/macros/Interrogate.cmake index eebe62abb5..aac4eec8c4 100644 --- a/cmake/macros/Interrogate.cmake +++ b/cmake/macros/Interrogate.cmake @@ -167,28 +167,14 @@ function(interrogate_sources target output database module) endforeach(source) # Interrogate also needs the include paths, so we'll extract them from the - # target. Usually these are available via a generator expression, however - # versions of CMake before 2.8.10 don't support the TARGET_PROPERTY genex - # so we have to extract the property at configuration-time. Versions after - # 2.8.11 support CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE which ONLY makes - # this information available at generator-time (i.e. after - # configuration-time) so the generator expression is necessary then. - if(CMAKE_VERSION VERSION_LESS 2.8.10) - set(include_flags) - get_target_property(include_dirs "${target}" INTERFACE_INCLUDE_DIRECTORIES) - foreach(include_dir ${include_dirs}) - list(APPEND include_flags "-I${include_dir}") - endforeach(include_dir) - # The above must also be included when compiling the resulting _igate.cxx file: - include_directories(${include_dirs}) - else() - # Note, the \t is a workaround for a CMake bug where using a plain space in - # a JOIN will cause it to be escaped. Tabs are not escaped and will - # separate correctly. - set(include_flags "-I$,\t-I>") - # The above must also be included when compiling the resulting _igate.cxx file: - include_directories("$") - endif() + # target. These are available via a generator expression. + + # Note, the \t is a workaround for a CMake bug where using a plain space in + # a JOIN will cause it to be escaped. Tabs are not escaped and will + # separate correctly. + set(include_flags "-I$,\t-I>") + # The above must also be included when compiling the resulting _igate.cxx file: + include_directories("$") # Get the compiler definition flags. These must be passed to Interrogate # in the same way that they are passed to the compiler so that Interrogate diff --git a/cmake/modules/AutoInclude.cmake b/cmake/modules/AutoInclude.cmake deleted file mode 100644 index c703734bfc..0000000000 --- a/cmake/modules/AutoInclude.cmake +++ /dev/null @@ -1,55 +0,0 @@ -# Filename: AutoInclude.cmake -# Description: This file backports the CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE -# introduced in CMake 2.8.11 to previous versions of cmake, and enables the -# behavior by default. -# - -# Emulate CMake 2.8.11's CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE behavior if -# this version doesn't define CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE. -if(CMAKE_VERSION VERSION_LESS 2.8.11) - # Replace some built-in functions in order to extend their functionality. - function(add_library target) - _add_library(${target} ${ARGN}) - set_target_properties("${target}" PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_BINARY_DIR}") - endfunction() - - function(add_executable target) - _add_executable(${target} ${ARGN}) - set_target_properties("${target}" PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_BINARY_DIR}") - endfunction() - - function(target_link_libraries target) - set(interface_dirs) - get_target_property(target_interface_dirs "${target}" INTERFACE_INCLUDE_DIRECTORIES) - - foreach(lib ${ARGN}) - if(TARGET "${lib}") - get_target_property(lib_interface_dirs "${lib}" INTERFACE_INCLUDE_DIRECTORIES) - - if(lib_interface_dirs) - list(APPEND interface_dirs ${lib_interface_dirs}) - endif() - endif() - endforeach() - - if(interface_dirs) - list(REMOVE_DUPLICATES interface_dirs) - - #NB. target_include_directories is new in 2.8.8. - #target_include_directories("${target}" ${interface_dirs}) - include_directories(${interface_dirs}) - - # Update this target's interface inc dirs. - set_target_properties("${target}" PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${target_interface_dirs};${interface_dirs}") - endif() - - # Call to the built-in function we are overriding. - _target_link_libraries(${target} ${ARGN}) - endfunction() - -else() - # 2.8.11 supports this natively. - set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) -endif() - -set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/cmake/scripts/MakeComposite.cmake b/cmake/scripts/MakeComposite.cmake index 11b618dad0..fb4d88f6b6 100644 --- a/cmake/scripts/MakeComposite.cmake +++ b/cmake/scripts/MakeComposite.cmake @@ -10,8 +10,6 @@ # if(CMAKE_SCRIPT_MODE_FILE) - #cmake_minimum_required(VERSION 2.8.4) - if(NOT DEFINED COMPOSITE_FILE) message(FATAL_ERROR "COMPOSITE_FILE should be defined when running MakeComposite.cmake!") return() diff --git a/panda/src/express/CMakeLists.txt b/panda/src/express/CMakeLists.txt index ff7cc014ee..7fa891c805 100644 --- a/panda/src/express/CMakeLists.txt +++ b/panda/src/express/CMakeLists.txt @@ -144,18 +144,11 @@ set(P3EXPRESS_IGATEEXT composite_sources(p3express P3EXPRESS_SOURCES) +add_library(p3express ${P3EXPRESS_SOURCES} ${P3EXPRESS_HEADERS}) + # p3express needs to include from p3interrogatedb for py_panda.h and extension.h -if(CMAKE_VERSION VERSION_LESS 2.8.11) - get_target_property(interrogatedb_interface_dirs p3interrogatedb INTERFACE_INCLUDE_DIRECTORIES) - include_directories(${interrogatedb_interface_dirs}) - add_library(p3express ${P3EXPRESS_SOURCES} ${P3EXPRESS_HEADERS}) - set_target_properties(p3express PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - "${interrogatedb_interface_dirs};${CMAKE_CURRENT_SOURCE_DIR}") -else() - add_library(p3express ${P3EXPRESS_SOURCES} ${P3EXPRESS_HEADERS}) - target_include_directories(p3express PUBLIC - $) -endif() +target_include_directories(p3express PUBLIC + $) target_link_libraries(p3express p3pandabase p3dtool p3prc p3dconfig) target_use_packages(p3express TAR ZLIB) target_interrogate(p3express ALL EXTENSIONS ${P3EXPRESS_IGATEEXT})