Split automated compiler settings into LocalSetup.cmake. Rename Version.cmake into PandaVersion.cmake.

This commit is contained in:
rdb 2013-12-14 14:51:36 +01:00
parent 7a66d4ea2f
commit 39bea67211
5 changed files with 191 additions and 92 deletions

View File

@ -5,10 +5,10 @@ project(Panda3D)
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")
include_directories("${CMAKE_BINARY_DIR}")
## Configure Panda3D ##(
include(dtool/Version.cmake)
include(dtool/PandaVersion.cmake)
include(dtool/Packages.cmake)
include(dtool/Config.cmake)

View File

@ -1,5 +1,5 @@
## Configure dtool ##
configure_file(dtool_config.h.cmake ${CMAKE_BINARY_DIR}/include/dtool_config.h)
include(LocalSetup.cmake)
## Include dtool subpackages ##
add_subdirectory(src/dtoolbase)

View File

@ -167,12 +167,12 @@ if(CMAKE_BUILD_TYPE MATCHES "MinSizeRel")
option(BUILD_WITH_DEFAULT_FONT
"If on, compiles in a default font, so that every TextNode will always
have a font available without requiring the user to specify one.
When turned off, the generated libary will save a few kilobytes." OFF)
When turned off, the generated library will save a few kilobytes." OFF)
else()
option(BUILD_WITH_DEFAULT_FONT
"If on, compiles in a default font, so that every TextNode will always
have a font available without requiring the user to specify one.
When turned off, the generated libary will save a few kilobytes." ON)
When turned off, the generated library will save a few kilobytes." ON)
endif()
if(BUILD_WITH_DEFAULT_FONT)
set(COMPILE_IN_DEFAULT_FONT TRUE)
@ -189,95 +189,15 @@ if(BUILD_PREFER_STDFLOAT)
set(STDFLOAT_DOUBLE TRUE)
endif()
### Check for system support of various values ###
# Do we have all these header files?
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)
check_include_file_cxx(typeinfo HAVE_RTTI)
check_include_file_cxx(getopt.h PHAVE_GETOPT_H)
# Do we have these sized type definitions
include(CheckTypeSize)
check_type_size(wchar_t WCHAR_T)
# Does the compiler accept these declarations
include(CheckCXXSourceCompiles)
check_cxx_source_compiles(
"#include <string>
std::wstring str;
int main(int argc, char *argv[]) { return 0; }"
HAVE_WSTRING)
# Do we have these standard functions
include(CheckFunctionExists)
check_function_exists(getopt HAVE_GETOPT)
check_function_exists(getopt_long_only HAVE_GETOPT_LONG_ONLY)
# Are we on a big endian system?
include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)
# Do we support std namespaces?
include(TestForSTDNamespace)
set(HAVE_NAMESPACE CMAKE_STD_NAMESPACE)
# Can we read the file /proc/self/[*] to determine our
# environment variables at static init time?
if(EXISTS "/proc/self/exe")
set(HAVE_PROC_SELF_EXE TRUE)
endif()
if(EXISTS "/proc/self/maps")
set(HAVE_PROC_SELF_MAPS TRUE)
endif()
if(EXISTS "/proc/self/environ")
set(HAVE_PROC_SELF_ENVIRON TRUE)
endif()
if(EXISTS "/proc/self/cmdline")
set(HAVE_PROC_SELF_CMDLINE TRUE)
endif()
if(EXISTS "/proc/curproc/file")
set(HAVE_PROC_CURPROC_FILE TRUE)
endif()
if(EXISTS "/proc/curproc/map")
set(HAVE_PROC_CURPROC_MAP TRUE)
endif()
if(EXISTS "/proc/curproc/cmdline")
set(HAVE_PROC_CURPROC_CMDLINE TRUE)
endif()
# TODO: Actually check for these, instead of assuming
set(HAVE_LOCKF TRUE)
set(HAVE_TYPENAME TRUE)
set(SIMPLE_STRUCT_POINTERS TRUE)
set(HAVE_STREAMSIZE TRUE)
set(HAVE_IOS_TYPEDEFS TRUE)
#XXX note from rdb: I've moved the automatically-configured
# compiler settings to LocalSetup.cmake, which is also where
# dtool_config.h.cmake is now being invoked.
# LocalSetup.cmake is included in dtool/CMakeLists.txt, which
# is OK since the variables in there don't have to be used
# outside of dtool_config.h.cmake.
if(WIN32)
set(DEFAULT_PATHSEP ";")
else()
set(DEFAULT_PATHSEP ":")
endif()
configure_file(dtool/dtool_config.h.cmake ${CMAKE_BINARY_DIR}/include/dtool_config.h)

179
dtool/LocalSetup.cmake Normal file
View File

@ -0,0 +1,179 @@
#
# LocalSetup.cmake
#
# This file contains further instructions to set up the DTOOL package
# when using CMake. In particular, it creates the dtool_config.h
# file based on the user's selected configure variables.
#
include(CheckCXXSourceCompiles)
include(CheckCSourceRuns)
include(CheckIncludeFileCXX)
include(CheckFunctionExists)
include(CheckTypeSize)
include(TestBigEndian)
include(TestForSTDNamespace)
# Define if we have libjpeg installed.
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.
test_big_endian(WORDS_BIGENDIAN)
# Check if the compiler supports namespaces.
set(HAVE_NAMESPACE ${CMAKE_STD_NAMESPACE})
# Define if fstream::open() accepts a third parameter for umask.
#TODO make test case
#$[cdefine HAVE_OPEN_MASK]
# Define if we have lockf().
#TODO make test case
set(HAVE_LOCKF 1)
# Check if we have a wchar_t type.
check_type_size(wchar_t HAVE_WCHAR_T)
# Check if we have a wstring type.
check_cxx_source_compiles("
#include <string>
std::wstring str;
int main(int argc, char *argv[]) { return 0; }
" HAVE_WSTRING)
# Define if the C++ compiler supports the typename keyword.
#TODO make test case (I had one but it broke)
set(HAVE_TYPENAME 1)
# Define if we can trust the compiler not to insert extra bytes in
# structs between base structs and derived structs.
check_c_source_runs("
struct A { int a; };
struct B : public A { int b; };
int main(int argc, char *argv[]) {
struct B i;
if ((size_t) &(i.b) == ((size_t) &(i.a)) + sizeof(struct A)) {
return 0;
} else {
return 1;
}
}" SIMPLE_STRUCT_POINTERS)
# Define if we have STL hash_map etc. available
#TODO make test case
#//$[cdefine HAVE_STL_HASH]
# Check if we have a gettimeofday() function.
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
# Define if gettimeofday() takes only one parameter.
check_cxx_source_compiles("
#include <sys/time.h>
int main(int argc, char *argv[]) {
struct timeval tv;
int result;
result = gettimeofday(&tv);
return 0;
}" GETTIMEOFDAY_ONE_PARAM)
# Check if we have getopt.
check_function_exists(getopt HAVE_GETOPT)
check_function_exists(getopt_long_only HAVE_GETOPT_LONG_ONLY)
check_include_file_cxx(getopt.h PHAVE_GETOPT_H)
# Define if you have ioctl(TIOCGWINSZ) to determine terminal width.
#XXX can we make a test case for this that isn't dependent on
# the current terminal? It might also be useful for Cygwin users.
if(UNIX)
set(IOCTL_TERMINAL_WIDTH 1)
endif()
# Do the system headers define a "streamsize" typedef?
check_cxx_source_compiles("
#include <ios>
std::streamsize ss;
int main(int argc, char *argv[]) { return 0; }
" HAVE_STREAMSIZE)
# Do the system headers define key ios typedefs like ios::openmode
# and ios::fmtflags?
#TODO make test case
set(HAVE_IOS_TYPEDEFS 1)
# Define if the C++ iostream library defines ios::binary.
#TODO make test case
#$[cdefine HAVE_IOS_BINARY]
# Can we safely call getenv() at static init time?
#TODO make test case? can we make a reliable one?
#$[cdefine STATIC_INIT_GETENV]
# Can we read the file /proc/self/[*] to determine our
# environment variables at static init time?
if(EXISTS "/proc/self/exe")
set(HAVE_PROC_SELF_EXE 1)
endif()
if(EXISTS "/proc/self/maps")
set(HAVE_PROC_SELF_MAPS 1)
endif()
if(EXISTS "/proc/self/environ")
set(HAVE_PROC_SELF_ENVIRON 1)
endif()
if(EXISTS "/proc/self/cmdline")
set(HAVE_PROC_SELF_CMDLINE 1)
endif()
if(EXISTS "/proc/curproc/file")
set(HAVE_PROC_CURPROC_FILE 1)
endif()
if(EXISTS "/proc/curproc/map")
set(HAVE_PROC_CURPROC_MAP 1)
endif()
if(EXISTS "/proc/curproc/cmdline")
set(HAVE_PROC_CURPROC_CMDLINE 1)
endif()
# Do we have a global pair of argc/argv variables that we can read at
# static init time? Should we prototype them? What are they called?
#TODO make test case
#$[cdefine HAVE_GLOBAL_ARGV]
#$[cdefine PROTOTYPE_GLOBAL_ARGV]
#$[cdefine GLOBAL_ARGV]
#$[cdefine GLOBAL_ARGC]
# Do we have all these header files?
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) #TODO doesn't work on OSX, use sys/ucontext.h
check_include_file_cxx(linux/input.h PHAVE_LINUX_INPUT_H)
check_include_file_cxx(stdint.h PHAVE_STDINT_H)
check_include_file_cxx(typeinfo HAVE_RTTI)
# Do we have Posix threads?
#set(HAVE_POSIX_THREADS ${CMAKE_USE_PTHREADS_INIT})
#/* Define if needed to have 64-bit file i/o */
#$[cdefine __USE_LARGEFILE64]
configure_file(dtool_config.h.cmake "${PROJECT_BINARY_DIR}/dtool_config.h")
#install(FILES "${PROJECT_BINARY_DIR}/dtool_config.h" DESTINATION include/panda3d)

View File

@ -61,7 +61,7 @@ else()
set(VERSION_SUFFIX "c")
endif()
set(PANDA_VERSION_STR "${PANDA_VERSION}c")
set(PANDA_VERSION_STR "${PANDA_VERSION}${VERSION_SUFFIX}")
# This symbol is used to enforce ABI incompatibility between
# major versions of Panda3D.