CMake: Rearrange CMake flow so that Version, Package, and Config information is available at the top level. Remove complexity from subpackages where possible.

This commit is contained in:
kestred 2013-12-13 14:06:36 -07:00
parent 905f0a8c55
commit fdcd21ad4c
6 changed files with 214 additions and 229 deletions

View File

@ -1,21 +1,17 @@
cmake_minimum_required(VERSION 2.8)
project(Panda3D)
## Panda Version Information ##
set(PANDA_VERSION 1 9 0)
set(PANDA_OFFICIAL_VERSION FALSE CACHE BOOL "If true, signifies this is a tagged release rather than a repository snapshot. Scripts that generate source tarballs and/or binary releases for distribution should explicitly set this to true.")
set(PANDA_DISTRIBUTOR "homebuilt" CACHE STRING "This should be set by whoever provides a particular distribution of Panda. If you build your own Panda, leave this unchanged.")
set(P3D_PLUGIN_VERSION 1 0 4)
set(P3D_COREAPI_VERSION ${P3D_PLUGIN_VERSION} 1)
## Set CMake Find<Foo> Module path ##
## Set Panda's CMake Module path ##
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
## This is where dtool_config.h gets generated ##
include_directories("${CMAKE_BINARY_DIR}/include")
## Configure Panda3D ##(
include(dtool/Version.cmake)
include(dtool/Packages.cmake)
include(dtool/Config.cmake)
## Include Panda3D Packages ##
add_subdirectory(dtool)
add_subdirectory(panda)

View File

@ -1,59 +1,5 @@
## Parse Panda3D Subversions ##
list(GET PANDA_VERSION 0 PANDA_MAJOR_VERSION)
list(GET PANDA_VERSION 1 PANDA_MINOR_VERSION)
list(GET PANDA_VERSION 2 PANDA_SEQUENCE_VERSION)
string(REPLACE ";" "." PANDA_VERSION_STR "${PANDA_VERSION}")
if(NOT PANDA_OFFICIAL_VERSION)
set(PANDA_VERSION_STR "${PANDA_VERSION_STR}c")
endif()
set(PANDA_VERSION_SYMBOL panda_version_${PANDA_MAJOR_VERSION}_${PANDA_MINOR_VERSION})
math(EXPR PANDA_NUMERIC_VERSION "${PANDA_MAJOR_VERSION}*1000000 + ${PANDA_MINOR_VERSION}*1000 + ${PANDA_SEQUENCE_VERSION}")
## Parse Plugin-framework Subversions ##
list(GET P3D_PLUGIN_VERSION 0 P3D_PLUGIN_MAJOR_VERSION)
list(GET P3D_PLUGIN_VERSION 1 P3D_PLUGIN_MINOR_VERSION)
list(GET P3D_PLUGIN_VERSION 2 P3D_PLUGIN_SEQUENCE_VERSION)
string(REPLACE ";" "." P3D_PLUGIN_VERSION_STR "${P3D_PLUGIN_VERSION}")
if(PANDA_OFFICIAL_VERSION)
set(P3D_PLUGIN_DLL_DOT_VERSION "${P3D_PLUGIN_VERSION_STR}.1000")
else()
set(P3D_PLUGIN_DLL_DOT_VERSION "${P3D_PLUGIN_VERSION_STR}.0")
set(P3D_PLUGIN_VERSION_STR "${P3D_PLUGIN_VERSION_STR}c")
endif()
string(REPLACE "." "," P3D_PLUGIN_DLL_COMMA_VERSION "${P3D_PLUGIN_DLL_DOT_VERSION}")
# PRC Config settings
set(PRC_DEFAULT_DIR_ABSOLUTE "" CACHE STRING "Specify the PRC_DEFAULT_DIR as an absolute path.")
if(NOT PRC_DEFAULT_DIR_ABSOLUTE)
set(PRC_DEFAULT_DIR "etc" CACHE STRING
"Panda uses prc files for runtime configuration. Panda will search the default
.prc directory if the PRC_PATH and PRC_DIR environment variables are not defined.")
else()
set(PRC_DEFAULT_DIR "" CACHE STRING
"Panda uses prc files for runtime configuration. Panda will search the default
.prc directory if the PRC_PATH and PRC_DIR environment variables are not defined.")
endif()
set(PRC_DCONFIG_TRUST_LEVEL 0 CACHE STRING "The trust level value for any legacy (DConfig) variables.")
set(PRC_INC_TRUST_LEVEL 0 CACHE STRING "The amount by which we globally increment the trust level.")
if(PRC_DEFAULT_DIR AND PRC_DEFAULT_DIR_ABSOLUTE)
message(FATAL_ERROR "Cannot have both PRC_DEFAULT_DIR and PRC_DEFAULT_DIR_ABSOLUTE, choose one.")
endif()
# PRC special values for config headers
if(PRC_DEFAULT_DIR_ABSOLUTE)
set(DEFAULT_PRC_DIR ${PRC_ABSOLUTE_DIR})
else()
set(DEFAULT_PRC_DIR "${CMAKE_INSTALL_PREFIX}/panda/${PRC_DEFAULT_DIR}")
endif()
include(Configure.cmake)
## Configure dtool ##
configure_file(dtool_config.h.cmake ${CMAKE_BINARY_DIR}/include/dtool_config.h)
## Include dtool subpackages ##
add_subdirectory(src/dtoolbase)

169
dtool/Config.cmake Normal file
View File

@ -0,0 +1,169 @@
# PRC Config settings
set(PRC_DEFAULT_DIR_ABSOLUTE "" CACHE STRING "Specify the PRC_DEFAULT_DIR as an absolute path.")
if(NOT PRC_DEFAULT_DIR_ABSOLUTE)
set(PRC_DEFAULT_DIR "etc" CACHE STRING
"Panda uses prc files for runtime configuration. Panda will search the default
.prc directory if the PRC_PATH and PRC_DIR environment variables are not defined.")
else()
set(PRC_DEFAULT_DIR "" CACHE STRING
"Panda uses prc files for runtime configuration. Panda will search the default
.prc directory if the PRC_PATH and PRC_DIR environment variables are not defined.")
endif()
set(PRC_DCONFIG_TRUST_LEVEL 0 CACHE STRING "The trust level value for any legacy (DConfig) variables.")
set(PRC_INC_TRUST_LEVEL 0 CACHE STRING "The amount by which we globally increment the trust level.")
if(PRC_DEFAULT_DIR AND PRC_DEFAULT_DIR_ABSOLUTE)
message(FATAL_ERROR "Cannot have both PRC_DEFAULT_DIR and PRC_DEFAULT_DIR_ABSOLUTE, choose one.")
endif()
# PRC special values for config headers
if(PRC_DEFAULT_DIR_ABSOLUTE)
set(DEFAULT_PRC_DIR ${PRC_ABSOLUTE_DIR})
else()
set(DEFAULT_PRC_DIR "${CMAKE_INSTALL_PREFIX}/panda/${PRC_DEFAULT_DIR}")
endif()
### Configure interrogate ###
message(STATUS "") # simple line break
if(HAVE_PYTHON AND HAVE_OPENSSL)
option(USE_INTERROGATE "If on, Panda3D will generate python interfaces" ON)
if(USE_INTERROGATE)
set(HAVE_INTERROGATE TRUE)
endif()
else()
unset(USE_INTERROGATE CACHE)
endif()
if(HAVE_INTERROGATE)
message(STATUS "Compilation will generate Python interfaces.")
else()
message(STATUS "Configuring Panda without Python interfaces.")
endif()
### Configure threading support ###
# Add basic use flag for threading
option(BUILD_THREADS "If on, compile Panda3D with threading support." ON)
if(BUILD_THREADS)
set(HAVE_THREADS TRUE)
else()
unset(BUILD_SIMPLE_THREADS CACHE)
unset(BUILD_OS_SIMPLE_THREADS CACHE)
endif()
# Configure debug threads
if(CMAKE_BUILD_TYPE MATCHES "Debug")
option(BUILD_DEBUG_THREADS "If on, enables debugging of thread and sync operations (i.e. mutexes, deadlocks)" ON)
else()
option(BUILD_DEBUG_THREADS "If on, enables debugging of thread and sync operations (i.e. mutexes, deadlocks)" OFF)
endif()
if(BUILD_DEBUG_THREADS)
set(DEBUG_THREADS TRUE)
endif()
# Add advanced threading configuration
if(HAVE_THREADS)
option(BUILD_SIMPLE_THREADS "If on, compile with simulated threads." OFF)
if(BUILD_SIMPLE_THREADS)
message(STATUS "Compilation will include simulated threading support.")
option(BUILD_OS_SIMPLE_THREADS "If on, OS threading constructs will be used to perform context switches." ON)
set(SIMPLE_THREADS TRUE)
if(BUILD_OS_SIMPLE_THREADS)
set(OS_SIMPLE_THREADS TRUE)
endif()
else()
unset(BUILD_OS_SIMPLE_THREADS CACHE)
option(BUILD_PIPELINING "If on, compile with pipelined rendering." ON)
if(BUILD_PIPELINING)
message(STATUS "Compilation will include full, pipelined threading support.")
else()
message(STATUS "Compilation will include nonpipelined threading support.")
endif()
endif()
else()
message(STATUS "Configuring Panda without threading support.")
endif()
set(HAVE_POSIX_THREADS FALSE)
if(NOT WIN32)
find_path(PTHREAD_INCLUDE_DIR
NAMES "pthread.h"
PATHS "/usr/include"
)
if(PTHREAD_INCLUDE_DIR)
set(HAVE_POSIX_THREADS TRUE)
set(CMAKE_CXX_FLAGS "-pthread")
set(CMAKE_CXX_FLAGS_DEBUG "-pthread")
set(CMAKE_CXX_FLAGS_RELEASE "-pthread")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-pthread")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-pthread")
mark_as_advanced(PTHREAD_INCLUDE_DIR)
endif()
endif()
### Configure pipelining ###
if(NOT DEFINED BUILD_PIPELINING)
option(BUILD_PIPELINING "If on, compile with pipelined rendering." ON)
endif()
if(BUILD_PIPELINING)
set(DO_PIPELINING TRUE)
endif()
### Configure OS X options ###
if(APPLE)
option(BUILD_UNIVERSIAL_BINARIES "If on, compiling will create universal OS X binaries." ON)
if(BUILD_UNIVERSAL_BINARIES)
message(STATUS "Compilation will create universal binaries.")
set(UNIVERSAL_BINARIES TRUE)
else()
message(STATUS "Compilation will not create universal binaries.")
endif()
endif()
message(STATUS "")
message(STATUS "See dtool_config.h for more details about the specified configuration.\n")
include(CheckIncludeFileCXX)
check_include_file_cxx(io.h PHAVE_IO_H)
check_include_file_cxx(iostream PHAVE_IOSTREAM)
check_include_file_cxx(malloc.h PHAVE_MALLOC_H)
check_include_file_cxx(sys/malloc.h PHAVE_SYS_MALLOC_H)
check_include_file_cxx(alloca.h PHAVE_ALLOCA_H)
check_include_file_cxx(locale.h PHAVE_LOCALE_H)
check_include_file_cxx(string.h PHAVE_STRING_H)
check_include_file_cxx(stdlib.h PHAVE_STDLIB_H)
check_include_file_cxx(limits.h PHAVE_LIMITS_H)
check_include_file_cxx(minmax.h PHAVE_MINMAX_H)
check_include_file_cxx(sstream PHAVE_SSTREAM)
check_include_file_cxx(new PHAVE_NEW)
check_include_file_cxx(sys/types.h PHAVE_SYS_TYPES_H)
check_include_file_cxx(sys/time.h PHAVE_SYS_TIME_H)
check_include_file_cxx(unistd.h PHAVE_UNISTD_H)
check_include_file_cxx(utime.h PHAVE_UTIME_H)
check_include_file_cxx(glob.h PHAVE_GLOB_H)
check_include_file_cxx(dirent.h PHAVE_DIRENT_H)
check_include_file_cxx(drfftw.h PHAVE_DRFFTW_H)
check_include_file_cxx(sys/soundcard.h PHAVE_SYS_SOUNDCARD_H)
check_include_file_cxx(ucontext.h PHAVE_UCONTEXT_H)
check_include_file_cxx(linux/input.h PHAVE_LINUX_INPUT_H)
check_include_file_cxx(stdint.h PHAVE_STDINT_H)
# TODO: Actually check for these, instead of assuming
set(HAVE_NAMESPACE ON)
set(HAVE_LOCKF ON)
set(HAVE_WCHAR_T ON)
set(HAVE_WSTRING ON)
set(HAVE_TYPENAME ON)
set(SIMPLE_STRUCT_POINTERS ON)
set(HAVE_STREAMSIZE ON)
set(HAVE_IOS_TYPEDEFS ON)
if(WIN32)
set(DEFAULT_PATHSEP ";")
else()
set(DEFAULT_PATHSEP ":")
endif()
configure_file(dtool/dtool_config.h.cmake ${CMAKE_BINARY_DIR}/include/dtool_config.h)

View File

@ -23,7 +23,6 @@ endif()
include(ConfigurePackage)
# Find and configure Eigen library
find_package(Eigen3 QUIET)
config_package(EIGEN "Eigen")
@ -273,151 +272,3 @@ endif()
# Find and configure Vorbis
#find_package(Vorbis)
#config_package(VORBIS COMMENT "Vorbis Ogg decoder")
### Configure interrogate ###
message(STATUS "") # simple line break
if(HAVE_PYTHON)
option(USE_INTERROGATE "If on, Panda3D will generate python interfaces" ON)
if(USE_INTERROGATE)
set(HAVE_INTERROGATE TRUE)
endif()
else()
unset(USE_INTERROGATE CACHE)
endif()
if(HAVE_INTERROGATE)
message(STATUS "Compilation will generate Python interfaces.")
else()
message(STATUS "Configuring Panda without Python interfaces.")
endif()
### Configure threading support ###
# Add basic use flag for threading
option(BUILD_THREADS "If on, compile Panda3D with threading support." ON)
if(BUILD_THREADS)
set(HAVE_THREADS TRUE)
else()
unset(BUILD_SIMPLE_THREADS CACHE)
unset(BUILD_OS_SIMPLE_THREADS CACHE)
endif()
# Configure debug threads
if(CMAKE_BUILD_TYPE MATCHES "Debug")
option(BUILD_DEBUG_THREADS "If on, enables debugging of thread and sync operations (i.e. mutexes, deadlocks)" ON)
else()
option(BUILD_DEBUG_THREADS "If on, enables debugging of thread and sync operations (i.e. mutexes, deadlocks)" OFF)
endif()
if(BUILD_DEBUG_THREADS)
set(DEBUG_THREADS TRUE)
endif()
# Add advanced threading configuration
if(HAVE_THREADS)
option(BUILD_SIMPLE_THREADS "If on, compile with simulated threads." OFF)
if(BUILD_SIMPLE_THREADS)
message(STATUS "Compilation will include simulated threading support.")
option(BUILD_OS_SIMPLE_THREADS "If on, OS threading constructs will be used to perform context switches." ON)
set(SIMPLE_THREADS TRUE)
if(BUILD_OS_SIMPLE_THREADS)
set(OS_SIMPLE_THREADS TRUE)
endif()
else()
unset(BUILD_OS_SIMPLE_THREADS CACHE)
option(BUILD_PIPELINING "If on, compile with pipelined rendering." ON)
if(BUILD_PIPELINING)
message(STATUS "Compilation will include full, pipelined threading support.")
else()
message(STATUS "Compilation will include nonpipelined threading support.")
endif()
endif()
else()
message(STATUS "Configuring Panda without threading support.")
endif()
set(HAVE_POSIX_THREADS FALSE)
if(NOT WIN32)
find_path(PTHREAD_IPATH
NAMES "pthread.h"
PATHS "/usr/include"
)
if(PTHREAD_IPATH)
set(HAVE_POSIX_THREADS TRUE)
set(THREAD_LIBS pthread)
set(CMAKE_CXX_FLAGS "-pthread")
set(CMAKE_CXX_FLAGS_DEBUG "-pthread")
set(CMAKE_CXX_FLAGS_RELEASE "-pthread")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-pthread")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-pthread")
mark_as_advanced(PTHREAD_IPATH)
endif()
endif()
### Configure pipelining ###
if(NOT DEFINED BUILD_PIPELINING)
option(BUILD_PIPELINING "If on, compile with pipelined rendering." ON)
endif()
if(BUILD_PIPELINING)
set(DO_PIPELINING TRUE)
endif()
### Configure OS X options ###
if(APPLE)
option(BUILD_UNIVERSIAL_BINARIES "If on, compiling will create universal OS X binaries." ON)
if(BUILD_UNIVERSAL_BINARIES)
message(STATUS "Compilation will create universal binaries.")
set(UNIVERSAL_BINARIES TRUE)
else()
message(STATUS "Compilation will not create universal binaries.")
endif()
endif()
message(STATUS "")
message(STATUS "See dtool_config.h for more details about the specified configuration.\n")
include(CheckIncludeFileCXX)
check_include_file_cxx(io.h PHAVE_IO_H)
check_include_file_cxx(iostream PHAVE_IOSTREAM)
check_include_file_cxx(malloc.h PHAVE_MALLOC_H)
check_include_file_cxx(sys/malloc.h PHAVE_SYS_MALLOC_H)
check_include_file_cxx(alloca.h PHAVE_ALLOCA_H)
check_include_file_cxx(locale.h PHAVE_LOCALE_H)
check_include_file_cxx(string.h PHAVE_STRING_H)
check_include_file_cxx(stdlib.h PHAVE_STDLIB_H)
check_include_file_cxx(limits.h PHAVE_LIMITS_H)
check_include_file_cxx(minmax.h PHAVE_MINMAX_H)
check_include_file_cxx(sstream PHAVE_SSTREAM)
check_include_file_cxx(new PHAVE_NEW)
check_include_file_cxx(sys/types.h PHAVE_SYS_TYPES_H)
check_include_file_cxx(sys/time.h PHAVE_SYS_TIME_H)
check_include_file_cxx(unistd.h PHAVE_UNISTD_H)
check_include_file_cxx(utime.h PHAVE_UTIME_H)
check_include_file_cxx(glob.h PHAVE_GLOB_H)
check_include_file_cxx(dirent.h PHAVE_DIRENT_H)
check_include_file_cxx(drfftw.h PHAVE_DRFFTW_H)
check_include_file_cxx(sys/soundcard.h PHAVE_SYS_SOUNDCARD_H)
check_include_file_cxx(ucontext.h PHAVE_UCONTEXT_H)
check_include_file_cxx(linux/input.h PHAVE_LINUX_INPUT_H)
check_include_file_cxx(stdint.h PHAVE_STDINT_H)
# TODO: Actually check for these, instead of assuming
set(HAVE_NAMESPACE ON)
set(HAVE_LOCKF ON)
set(HAVE_WCHAR_T ON)
set(HAVE_WSTRING ON)
set(HAVE_TYPENAME ON)
set(SIMPLE_STRUCT_POINTERS ON)
set(HAVE_STREAMSIZE ON)
set(HAVE_IOS_TYPEDEFS ON)
if(WIN32)
set(DEFAULT_PATHSEP ";")
else()
set(DEFAULT_PATHSEP ":")
endif()
configure_file(dtool_config.h.cmake ${CMAKE_BINARY_DIR}/include/dtool_config.h)

37
dtool/Version.cmake Normal file
View File

@ -0,0 +1,37 @@
## Panda Version Information ##
set(PANDA_VERSION 1 9 0)
set(PANDA_OFFICIAL_VERSION FALSE CACHE BOOL "If true, signifies this is a tagged release rather than a repository snapshot. Scripts that generate source tarballs and/or binary releases for distribution should explicitly set this to true.")
set(PANDA_DISTRIBUTOR "homebuilt" CACHE STRING "This should be set by whoever provides a particular distribution of Panda. If you build your own Panda, leave this unchanged.")
set(P3D_PLUGIN_VERSION 1 0 4)
set(P3D_COREAPI_VERSION ${P3D_PLUGIN_VERSION} 1)
## Parse Panda3D Subversions ##
list(GET PANDA_VERSION 0 PANDA_MAJOR_VERSION)
list(GET PANDA_VERSION 1 PANDA_MINOR_VERSION)
list(GET PANDA_VERSION 2 PANDA_SEQUENCE_VERSION)
string(REPLACE ";" "." PANDA_VERSION_STR "${PANDA_VERSION}")
if(NOT PANDA_OFFICIAL_VERSION)
set(PANDA_VERSION_STR "${PANDA_VERSION_STR}c")
endif()
set(PANDA_VERSION_SYMBOL panda_version_${PANDA_MAJOR_VERSION}_${PANDA_MINOR_VERSION})
math(EXPR PANDA_NUMERIC_VERSION "${PANDA_MAJOR_VERSION}*1000000 + ${PANDA_MINOR_VERSION}*1000 + ${PANDA_SEQUENCE_VERSION}")
## Parse Plugin-framework Subversions ##
list(GET P3D_PLUGIN_VERSION 0 P3D_PLUGIN_MAJOR_VERSION)
list(GET P3D_PLUGIN_VERSION 1 P3D_PLUGIN_MINOR_VERSION)
list(GET P3D_PLUGIN_VERSION 2 P3D_PLUGIN_SEQUENCE_VERSION)
string(REPLACE ";" "." P3D_PLUGIN_VERSION_STR "${P3D_PLUGIN_VERSION}")
if(PANDA_OFFICIAL_VERSION)
set(P3D_PLUGIN_DLL_DOT_VERSION "${P3D_PLUGIN_VERSION_STR}.1000")
else()
set(P3D_PLUGIN_DLL_DOT_VERSION "${P3D_PLUGIN_VERSION_STR}.0")
set(P3D_PLUGIN_VERSION_STR "${P3D_PLUGIN_VERSION_STR}c")
endif()
string(REPLACE "." "," P3D_PLUGIN_DLL_COMMA_VERSION "${P3D_PLUGIN_DLL_DOT_VERSION}")

View File

@ -6,20 +6,6 @@ include_directories(../dtoolbase)
include_directories(../pystub)
include_directories(../prc)
# OpenSSL is required for Interrogate
# Check for it here, so that Interrogate can be compiled individually
if(HAVE_OPENSSL)
include_directories(OPENSSL_IPATH)
else()
find_package(OpenSSL REQUIRED QUIET)
if(NOT OPENSSL_FOUND)
message(FATAL_ERROR "Interrogate requires OpenSSL.")
endif()
include_directories(${OPENSSL_INCLUDE_DIR})
endif()
set(INTERROGATE_HEADERS
functionRemap.h
functionWriter.h