package macros, add stuff to Config.cmake

This commit is contained in:
rdb 2013-12-22 00:18:57 +01:00
parent 3fa270b302
commit 5fdf4828be
5 changed files with 268 additions and 21 deletions

View File

@ -13,6 +13,7 @@ include_directories("${CMAKE_BINARY_DIR}")
include(dtool/PandaMacros.cmake) include(dtool/PandaMacros.cmake)
include(dtool/PandaVersion.cmake) include(dtool/PandaVersion.cmake)
include(dtool/Packages.cmake) include(dtool/Packages.cmake)
include(dtool/PackageMacros.cmake)
include(dtool/Config.cmake) include(dtool/Config.cmake)
include(dtool/Interrogate.cmake) include(dtool/Interrogate.cmake)

View File

@ -6,6 +6,19 @@
# generate build scripts appropriate to each environment. # generate build scripts appropriate to each environment.
# #
# Define the plaform we are building on.
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(IS_LINUX 1)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(IS_OSX 1)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(IS_FREEBSD 1)
endif()
# The character used to separate components of an OS-specific # The character used to separate components of an OS-specific
# directory name depends on the platform (it is '/' on Unix, '\' on # directory name depends on the platform (it is '/' on Unix, '\' on
# Windows). That character selection is hardcoded into Panda and # Windows). That character selection is hardcoded into Panda and
@ -254,13 +267,23 @@ endif()
# Now let's check for the presence of various thirdparty libraries. # Now let's check for the presence of various thirdparty libraries.
# #
option(USE_EIGEN find_package(Eigen3)
package_option(EIGEN
"Enables experimental support for the Eigen linear algebra library. "Enables experimental support for the Eigen linear algebra library.
If this is provided, Panda will use this library as the fundamental If this is provided, Panda will use this library as the fundamental
implementation of its own linmath library; otherwise, it will use implementation of its own linmath library; otherwise, it will use
its own internal implementation. The primary advantage of using its own internal implementation. The primary advantage of using
Eigen is SSE2 support, which is only activated if LINMATH_ALIGN Eigen is SSE2 support, which is only activated if LINMATH_ALIGN
is also enabled." ON) is also enabled.")
#option(USE_EIGEN
# "Enables experimental support for the Eigen linear algebra library.
#If this is provided, Panda will use this library as the fundamental
#implementation of its own linmath library; otherwise, it will use
#its own internal implementation. The primary advantage of using
#Eigen is SSE2 support, which is only activated if LINMATH_ALIGN
#is also enabled." ON)
option(LINMATH_ALIGN option(LINMATH_ALIGN
"This is required for activating SSE2 support using Eigen. "This is required for activating SSE2 support using Eigen.
@ -268,25 +291,37 @@ Activating this does constrain most objects in Panda to 16-byte
alignment, which could impact memory usage on very-low-memory alignment, which could impact memory usage on very-low-memory
platforms. Currently experimental." ON) platforms. Currently experimental." ON)
if(USE_EIGEN) #if(USE_EIGEN)
find_package(Eigen3) # find_package(Eigen3)
if(EIGEN3_FOUND) # if(EIGEN3_FOUND)
set(HAVE_EIGEN3 TRUE) # set(HAVE_EIGEN3 TRUE)
endif() # endif()
endif() #endif()
option(USE_PYTHON find_package(PythonLibs)
find_package(PythonInterp)
set(PYTHON_FOUND ${PYTHONLIBS_FOUND})
package_option(PYTHON DEFAULT ON
"Enables support for Python. If INTERROGATE_PYTHON_INTERFACE "Enables support for Python. If INTERROGATE_PYTHON_INTERFACE
is also enabled, Python bindings will be generated." ON) is also enabled, Python bindings will be generated.")
if(USE_PYTHON) # Always include Python, because we include it pretty much everywhere
find_package(PythonLibs) # though we don't usually want to link it in as well.
find_package(PythonInterp) include_directories(${PYTHON_INCLUDE_DIRS})
if(PYTHONLIBS_FOUND)
set(HAVE_PYTHON TRUE) #option(USE_PYTHON
include_directories("${PYTHON_INCLUDE_DIR}") # "Enables support for Python. If INTERROGATE_PYTHON_INTERFACE
endif() #is also enabled, Python bindings will be generated." ON)
endif()
#if(USE_PYTHON)
# find_package(PythonLibs)
# find_package(PythonInterp)
# if(PYTHONLIBS_FOUND)
# set(HAVE_PYTHON TRUE)
# include_directories("${PYTHON_INCLUDE_DIR}")
# endif()
#endif()
# By default, we'll assume the user only wants to run with Debug # By default, we'll assume the user only wants to run with Debug
# python if he has to--that is, on Windows when building a debug build. # python if he has to--that is, on Windows when building a debug build.
@ -366,6 +401,110 @@ mark_as_advanced(DO_MEMORY_USAGE SIMULATE_NETWORK_DELAY
SUPPORT_IMMEDIATE_MODE USE_MEMORY_DLMALLOC USE_MEMORY_PTMALLOC2 SUPPORT_IMMEDIATE_MODE USE_MEMORY_DLMALLOC USE_MEMORY_PTMALLOC2
MEMORY_HOOK_DO_ALIGN ALTERNATIVE_MALLOC USE_DELETED_CHAIN) MEMORY_HOOK_DO_ALIGN ALTERNATIVE_MALLOC USE_DELETED_CHAIN)
option(HAVE_WIN_TOUCHINPUT
"Define this if you are building on Windows 7 or better, and you
want your Panda build to run only on Windows 7 or better, and you
need to use the Windows touchinput interfaces." OFF)
option(WANT_NATIVE_NET
"Define this true to build the low-level native network
implementation. Normally this should be set true." ON)
option(HAVE_NET
"Do you want to build the high-level network interface? This layers
on top of the low-level native_net interface, specified above.
Normally, if you build NATIVE_NET, you will also build NET."
${WANT_NATIVE_NET})
option(HAVE_EGG
"Do you want to build the egg loader? Usually there's no reason to
avoid building this, unless you really want to make a low-footprint
build (such as, for instance, for the iPhone)." ON)
# Is OpenSSL installed, and where?
find_package(OpenSSL)
package_option(OPENSSL DEFAULT ON
"Enable OpenSSL support")
option(REPORT_OPENSSL_ERRORS
"Define this true to include the OpenSSL code to report verbose
error messages when they occur." ${DO_DEBUG})
# Is libjpeg installed, and where?
find_package(JPEG)
package_option(JPEG DEFAULT ON
"Enable support for loading .jpg images.")
# Some versions of libjpeg did not provide jpegint.h. Redefine this
# to false if you lack this header file.
#set(PHAVE_JPEGINT_H TRUE)
option(HAVE_VIDEO4LINUX
"Set this to enable webcam support on Linux." ${IS_LINUX})
# Is libpng installed, and where?
find_package(PNG)
package_option(PNG DEFAULT ON
"Enable support for loading .png images.")
# Is libtiff installed, and where?
find_package(TIFF)
package_option(TIFF
"Enable support for loading .tif images.")
# These image formats don't require the assistance of a
# third-party library to read and write, so there's normally no
# reason to disable them int he build, unless you are looking to
# reduce the memory footprint.
option(HAVE_SGI_RGB "Enable support for loading SGI RGB images." ON)
option(HAVE_TGA "Enable support for loading TGA images." ON)
option(HAVE_IMG "Enable support for loading IMG images." ON)
option(HAVE_SOFTIMAGE_PIC "Enable support for loading SOFTIMAGE PIC images." ON)
option(HAVE_BMP "Enable support for loading BMP images." ON)
option(HAVE_PNM "Enable support for loading PNM images." ON)
mark_as_advanced(HAVE_SGI_RGB HAVE_TGA
HAVE_IMG HAVE_SOFTIMAGE_PIC HAVE_BMP HAVE_PNM)
# Is libtar installed, and where?
find_package(Tar)
package_option(TAR
"This is used to optimize patch generation against tar files.")
# Is libfftw installed, and where?
find_package(FFTW)
package_option(FFTW
"This enables support for lossless compression of animations in
.bam files. This is rarely used, and you probably don't need it.")
#TODO PHAVE_DRFFTW_H
# Is libsquish installed, and where?
find_package(Squish)
package_option(SQUISH
"Enables support for automatic compression of DXT textures.")
#TODO: Cg HERE!
# Is VRPN installed, and where?
find_package(VRPN)
package_option(VRPN
"Enables support for connecting to VRPN servers.")
# Is ZLIB installed, and where?
find_package(ZLIB)
package_option(ZLIB DEFAULT ON
"Enables support for compression of Panda assets.")
# #
# < Insert the rest of the Config.pp port here < # < Insert the rest of the Config.pp port here <

View File

@ -17,9 +17,6 @@ include(TestForSTDNamespace)
# Define if we have libjpeg installed. # Define if we have libjpeg installed.
check_include_file_cxx(jpegint.h PHAVE_JPEGINT_H) check_include_file_cxx(jpegint.h PHAVE_JPEGINT_H)
# Define to build video-for-linux.
check_include_file_cxx(linux/videodev2.h HAVE_VIDEO4LINUX)
# Check if this is a big-endian system. # Check if this is a big-endian system.
test_big_endian(WORDS_BIGENDIAN) test_big_endian(WORDS_BIGENDIAN)
@ -182,6 +179,38 @@ else()
set(LINK_ALL_STATIC ON) set(LINK_ALL_STATIC ON)
endif() endif()
# Now go through all the packages and report whether we have them.
message(STATUS "Configuring support for the following optional third-party packages:")
#report_package(EIGEN "Eigen linear algebra library")
if(LINMATH_ALIGN)
message("+ (vectorization enabled in build)")
else()
message("- (vectorization NOT enabled in build)")
endif()
if(HAVE_INTERROGATE AND HAVE_PYTHON)
message("Compilation will generate Python interfaces.")
else()
message("Configuring Panda WITHOUT Python interfaces.")
endif()
if(HAVE_THREADS)
if(SIMPLE_THREADS)
message("Compilation will include simulated threading support.")
elseif(DO_PIPELINING)
message("Compilation will include full, pipelined threading support.")
else()
message("Compilation will include nonpipelined threading support.")
endif()
else()
message("Configuring Panda without threading support.")
endif()
message("See dtool_config.h for more details about the specified configuration.")
# Generate dtool_config.h # Generate dtool_config.h
configure_file(dtool_config.h.in "${PROJECT_BINARY_DIR}/dtool_config.h") configure_file(dtool_config.h.in "${PROJECT_BINARY_DIR}/dtool_config.h")
include_directories("${PROJECT_BINARY_DIR}") include_directories("${PROJECT_BINARY_DIR}")

77
dtool/PackageMacros.cmake Normal file
View File

@ -0,0 +1,77 @@
# Filename: ConfigurePackage.cmake
# Author: kestred (30 Nov, 2013)
#
# This modules defines a function which finds and configures libraries
# and packages for Panda3Ds configuration file headers (.h files).
#
# Assumes the file has already been found with find_package().
#
#
# Usage:
# package_option(PYTHON "Enables support for Python" [DEFAULT ON | OFF])
# If no default is given, it is initialized to whether it was found on the system.
#
function(package_option name)
# Parse the arguments.
set(command)
set(default)
set(cache_string)
foreach(arg ${ARGN})
if(command STREQUAL "DEFAULT")
set(default "${arg}")
set(command)
elseif(arg STREQUAL "DEFAULT")
set(command "DEFAULT")
else()
# Yes, a list, ecause semicolons can be in there, and
# that gets split up into multiple args, so we have to
# join it back together here.
list(APPEND cache_string "${arg}")
endif()
endforeach()
if(command STREQUAL "DEFAULT")
message(SEND_ERROR "DEFAULT in package_option takes an argument")
endif()
# If the default is not set, we set it.
if(NOT DEFINED default)
set(default "${${name}_FOUND}")
endif()
# If it was set by the user but not found, display an error.
if(HAVE_${name} AND NOT ${name}_FOUND)
message(SEND_ERROR "NOT FOUND: ${name}. Disable HAVE_${name} to continue.")
endif()
# Create the option.
option("HAVE_${name}" "${cache_string}" "${default}")
endfunction()
#
# Useful macro that picks up a package located using find_package
# as dependencies of a target that is going to be built.
# Example use:
# add_library(mylib ${SOURCES})
# target_use_packages(mylib PYTHON PNG)
#
macro(target_use_packages target)
set(libs ${ARGV})
list(REMOVE_AT libs 0)
foreach(lib ${libs})
if(HAVE_${lib})
target_include_directories("${target}" PUBLIC "${${lib}_INCLUDE_DIRS};${${lib}_INCLUDE_DIR}")
if(${lib}_LIBRARIES)
target_link_libraries("${target}" ${${lib}_LIBRARIES})
else()
target_link_libraries("${target}" ${${lib}_LIBRARY})
endif()
endif()
endforeach(lib)
endmacro(target_use_packages)

View File

@ -62,3 +62,4 @@ set(P3DTOOLBASE_SOURCES
composite_sources(p3dtoolbase P3DTOOLBASE_SOURCES) composite_sources(p3dtoolbase P3DTOOLBASE_SOURCES)
add_library(p3dtoolbase ${P3DTOOLBASE_HEADERS} ${P3DTOOLBASE_SOURCES}) add_library(p3dtoolbase ${P3DTOOLBASE_HEADERS} ${P3DTOOLBASE_SOURCES})