panda3d/CMakeLists.txt
Sam Edwards de03c2f7ff CMake: Use gnu++* instead of c++*
This is for consistency with the CMake 3.1+ behavior and allows the use of
GNU extensions.

Thanks @rdb!
2017-02-15 04:00:37 -07:00

98 lines
3.3 KiB
CMake

# 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)
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)
enable_testing()
# Panda3D is now a C++11 project. Newer versions of CMake support this out of
# the box; for older versions we take a shot in the dark:
if(CMAKE_VERSION VERSION_LESS "3.1")
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=gnu++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
endif()
else()
set(CMAKE_CXX_STANDARD 11)
endif()
# Add generic modules to cmake module path,
# and add Panda3D specific modules to cmake module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/macros/")
# Include global modules needed for configure scripts
include(PackageConfig) # Defines package_option AND target_use_packages
# Configure Panda3D
include(dtool/PandaVersion.cmake)
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
include(Interrogate) # Defines target_interrogate AND add_python_module
# Add the include path for source and header files generated by CMake
include_directories("${CMAKE_BINARY_DIR}/include")
# Determine which trees to build.
option(BUILD_DTOOL "Build the dtool source tree." ON)
option(BUILD_PANDA "Build the panda source tree." ON)
option(BUILD_DIRECT "Build the direct source tree." ON)
option(BUILD_PANDATOOL "Build the pandatool source tree." ON)
# Include Panda3D packages
if(BUILD_DTOOL)
add_subdirectory(dtool)
endif()
if(BUILD_PANDA)
add_subdirectory(panda)
endif()
if(BUILD_DIRECT)
add_subdirectory(direct)
endif()
if(BUILD_PANDATOOL)
add_subdirectory(pandatool)
endif()
# This bit is to generate the 'pandac' compatibility shim. It's deprecated now,
# but in older versions of Panda3D, one would use
# from pandac.PandaModules import *
# instead of
# from panda3d.FOO import *
if(HAVE_PYTHON)
# Generate PandaModules:
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pandac/PandaModules.py"
"\"This module is deprecated. Import from panda3d.core and other panda3d.* modules instead.\"
print(\"Warning: pandac.PandaModules is deprecated, import from panda3d.core instead\")\n")
foreach(module ${ALL_INTERROGATE_MODULES})
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/pandac/PandaModules.py" "
try:
from panda3d.${module} import *
except ImportError as err:
if \"No module named %s\" not in str(err):
raise
")
endforeach()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pandac/__init__.py" "")
# Now install ourselves:
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/pandac/__init__.py" "${CMAKE_CURRENT_BINARY_DIR}/pandac/PandaModules.py"
DESTINATION "${PYTHON_LIB_INSTALL_DIR}/pandac")
endif()