Browse Source

CMake: Move some symbols from dtool_config.h to -D flags

The symbols moved aren't used in any headers, so they don't
have to be in the installed dtool_config.h. Removing them
keeps the recompiling to a minimum when an optional feature
is toggled.
Sam Edwards 6 years ago
parent
commit
b8f3c7eb63

+ 0 - 79
dtool/dtool_config.h.in

@@ -21,9 +21,6 @@
 /* Define if we have Freetype 2.0 or better available. */
 #cmakedefine HAVE_FREETYPE
 
-/* Define if we have HarfBuzz available. */
-#cmakedefine HAVE_HARFBUZZ
-
 /* Define if we want to compile in a default font. */
 #cmakedefine COMPILE_IN_DEFAULT_FONT
 
@@ -33,9 +30,6 @@
 /* Define if we have built libRocket available and built with Python support. */
 #cmakedefine HAVE_ROCKET_PYTHON
 
-/* Define if we have FCollada available. */
-#cmakedefine HAVE_FCOLLADA
-
 /* Define if we have ARToolKit available. */
 #cmakedefine HAVE_ARTOOLKIT
 
@@ -47,7 +41,6 @@
 
 /* Define if we have OpenSSL installed.  */
 #cmakedefine HAVE_OPENSSL
-#cmakedefine REPORT_OPENSSL_ERRORS
 
 /* Define if we have libjpeg installed.  */
 #cmakedefine HAVE_JPEG
@@ -75,12 +68,6 @@
 /* Define if we have libtar installed.  */
 #cmakedefine HAVE_TAR
 
-/* Define if we have libfftw3 installed.  */
-#cmakedefine HAVE_FFTW
-
-/* Define if we have libsquish installed.  */
-#cmakedefine HAVE_SQUISH
-
 /* Define if we have CG installed.  */
 #cmakedefine HAVE_CG
 
@@ -88,30 +75,16 @@
 #cmakedefine HAVE_ZLIB
 
 /* Define if we have OpenGL installed and want to build for GL.  */
-#cmakedefine HAVE_GL
-#ifdef HAVE_GL
 #cmakedefine MIN_GL_VERSION_MAJOR
 #cmakedefine MIN_GL_VERSION_MINOR
-#endif
 
 /* Define if we have OpenCV installed and want to build for OpenCV.  */
 #cmakedefine HAVE_OPENCV
 
-/* Define if we have FFMPEG installed and want to build for FFMPEG.  */
-#cmakedefine HAVE_FFMPEG
-#cmakedefine HAVE_SWSCALE
-#cmakedefine HAVE_SWRESAMPLE
-
-/* Define if we have DirectX installed and want to build for DX.  */
-#cmakedefine HAVE_DX9
-
 /* The choice of generic vs. the specific dxerr library largely
    depends on which SDK you have installed. */
 #cmakedefine USE_GENERIC_DXERR_LIBRARY
 
-/* Define if we want to build tinydisplay. */
-#cmakedefine HAVE_TINYDISPLAY
-
 /* Define if we have the SDL library. */
 #cmakedefine HAVE_SDL
 
@@ -124,10 +97,6 @@
 /* Define if we want to use fast, user-space simulated threads.  */
 #cmakedefine SIMPLE_THREADS
 
-/* Define if SIMPLE_THREADS should be implemented with the OS-provided
-   threading layer (if available). */
-#cmakedefine OS_SIMPLE_THREADS
-
 /* Define to enable deadlock detection, mutex recursion checks, etc. */
 #cmakedefine DEBUG_THREADS
 
@@ -140,9 +109,6 @@
 /* Define if we want to compile the net code.  */
 #cmakedefine HAVE_NET
 
-/* Define if we want to compile the egg code.  */
-#cmakedefine HAVE_EGG
-
 /* Define if we want to compile the audio code.  */
 #cmakedefine HAVE_AUDIO
 
@@ -196,9 +162,6 @@
    byte first (like Motorola and SPARC, unlike Intel and VAX).  */
 #cmakedefine WORDS_BIGENDIAN
 
-/* Define if we have a lockf() function. */
-#cmakedefine PHAVE_LOCKF
-
 /* Define if we can trust the compiler not to insert extra bytes in
    structs between base structs and derived structs. */
 #cmakedefine SIMPLE_STRUCT_POINTERS
@@ -209,9 +172,6 @@
 /* Define if we have STL hash_map etc. available  */
 #cmakedefine HAVE_STL_HASH
 
-/* Define if gettimeofday() takes only one parameter. */
-#cmakedefine GETTIMEOFDAY_ONE_PARAM
-
 /* Define if you have the getopt function.  */
 #cmakedefine HAVE_GETOPT
 
@@ -221,36 +181,10 @@
 /* Define if getopt appears in getopt.h.  */
 #cmakedefine PHAVE_GETOPT_H
 
-/* Define if you have ioctl(TIOCGWINSZ) to determine terminal width. */
-#cmakedefine IOCTL_TERMINAL_WIDTH
-
 /* Do the system headers define key ios typedefs like ios::openmode
    and ios::fmtflags? */
 #cmakedefine HAVE_IOS_TYPEDEFS
 
-/* Define if the C++ iostream library defines ios::binary.  */
-#cmakedefine HAVE_IOS_BINARY
-
-/* Can we safely call getenv() at static init time? */
-#cmakedefine STATIC_INIT_GETENV
-
-/* Can we read the file /proc/self/[*] to determine our
-   environment variables at static init time? */
-#cmakedefine HAVE_PROC_SELF_EXE
-#cmakedefine HAVE_PROC_SELF_MAPS
-#cmakedefine HAVE_PROC_SELF_ENVIRON
-#cmakedefine HAVE_PROC_SELF_CMDLINE
-#cmakedefine HAVE_PROC_CURPROC_FILE
-#cmakedefine HAVE_PROC_CURPROC_MAP
-#cmakedefine HAVE_PROC_CURPROC_CMDLINE
-
-/* 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? */
-#cmakedefine HAVE_GLOBAL_ARGV
-#cmakedefine PROTOTYPE_GLOBAL_ARGV
-#cmakedefine GLOBAL_ARGV
-#cmakedefine GLOBAL_ARGC
-
 /* Define if you have the <io.h> header file.  */
 #cmakedefine PHAVE_IO_H
 
@@ -293,19 +227,6 @@
 /* Define if you have the <unistd.h> header file.  */
 #cmakedefine PHAVE_UNISTD_H
 
-/* Define if you have the <utime.h> header file.  */
-#cmakedefine PHAVE_UTIME_H
-
-/* Define if you have the <glob.h> header file.  */
-#cmakedefine PHAVE_GLOB_H
-
-/* Define if you have the <dirent.h> header file.  */
-#cmakedefine PHAVE_DIRENT_H
-
-/* Do we have <ucontext.h> (and therefore makecontext() /
-   swapcontext())? */
-#cmakedefine PHAVE_UCONTEXT_H
-
 /* Do we have <linux/input.h> ? This enables us to use raw mouse input. */
 #cmakedefine PHAVE_LINUX_INPUT_H
 

+ 32 - 0
dtool/src/dtoolutil/CMakeLists.txt

@@ -83,6 +83,38 @@ if(APPLE)
   target_link_libraries(p3dtoolutil ${FOUNDATION_LIBRARY} ${APPKIT_LIBRARY})
 endif()
 
+# These are all used by executionEnvironment.cxx/filename.cxx
+foreach(var
+    # executionEnvironment.cxx:
+    HAVE_GLOBAL_ARGV
+    PROTOTYPE_GLOBAL_ARGV
+    GLOBAL_ARGV
+    GLOBAL_ARGC
+
+    HAVE_PROC_CURPROC_CMDLINE
+    HAVE_PROC_CURPROC_FILE
+    HAVE_PROC_CURPROC_MAP
+    HAVE_PROC_SELF_CMDLINE
+    HAVE_PROC_SELF_ENVIRON
+    HAVE_PROC_SELF_EXE
+    HAVE_PROC_SELF_MAPS
+
+    STATIC_INIT_GETENV
+
+    # filename.cxx:
+    HAVE_IOS_BINARY
+    PHAVE_DIRENT_H
+    PHAVE_GLOB_H
+    PHAVE_LOCKF
+    PHAVE_UTIME_H
+)
+
+  if(${var})
+    target_compile_definitions(p3dtoolutil PRIVATE "${var}=${${var}}")
+  endif()
+
+endforeach(var)
+
 if(NOT BUILD_METALIBS)
   install(TARGETS p3dtoolutil
     EXPORT Core COMPONENT Core

+ 8 - 0
panda/src/express/CMakeLists.txt

@@ -140,6 +140,14 @@ target_link_libraries(p3express p3pandabase p3dtoolconfig p3dtool
   PKG::TAR PKG::ZLIB PKG::OPENSSL)
 target_interrogate(p3express ALL EXTENSIONS ${P3EXPRESS_IGATEEXT})
 
+if(REPORT_OPENSSL_ERRORS)
+  target_compile_definitions(p3express PRIVATE REPORT_OPENSSL_ERRORS)
+endif()
+
+if(GETTIMEOFDAY_ONE_PARAM)
+  target_compile_definitions(p3express PRIVATE GETTIMEOFDAY_ONE_PARAM)
+endif()
+
 if(WIN32)
   target_link_libraries(p3express advapi32.lib ws2_32.lib)
 endif()

+ 8 - 0
panda/src/ffmpeg/CMakeLists.txt

@@ -26,6 +26,14 @@ set_target_properties(p3ffmpeg PROPERTIES DEFINE_SYMBOL BUILDING_FFMPEG)
 target_link_libraries(p3ffmpeg panda
   PKG::FFMPEG PKG::SWSCALE PKG::SWRESAMPLE)
 
+if(HAVE_SWSCALE)
+  target_compile_definitions(p3ffmpeg PRIVATE HAVE_SWSCALE)
+endif()
+
+if(HAVE_SWRESAMPLE)
+  target_compile_definitions(p3ffmpeg PRIVATE HAVE_SWRESAMPLE)
+endif()
+
 install(TARGETS p3ffmpeg
   EXPORT FFmpeg COMPONENT FFmpeg
   DESTINATION lib

+ 13 - 0
panda/src/framework/CMakeLists.txt

@@ -38,6 +38,19 @@ add_library(p3framework ${P3FRAMEWORK_HEADERS} ${P3FRAMEWORK_SOURCES})
 set_target_properties(p3framework PROPERTIES DEFINE_SYMBOL BUILDING_FRAMEWORK)
 target_link_libraries(p3framework ${P3FRAMEWORK_LINK_TARGETS})
 
+foreach(var
+    HAVE_GL
+    HAVE_TINYDISPLAY
+    HAVE_DX9
+    HAVE_EGG
+)
+
+  if(${var})
+    target_compile_definitions(p3framework PRIVATE ${var})
+  endif()
+
+endforeach(var)
+
 install(TARGETS p3framework
   EXPORT Framework COMPONENT Framework
   DESTINATION lib

+ 8 - 0
panda/src/gobj/CMakeLists.txt

@@ -176,6 +176,14 @@ target_link_libraries(p3gobj p3gsgbase p3pnmimage
   PKG::ZLIB PKG::SQUISH PKG::CG)
 target_interrogate(p3gobj ALL EXTENSIONS ${P3GOBJ_IGATEEXT})
 
+if(HAVE_SQUISH)
+  target_compile_definitions(p3gobj PRIVATE HAVE_SQUISH)
+endif()
+
+if(PHAVE_LOCKF)
+  target_compile_definitions(p3gobj PRIVATE PHAVE_LOCKF)
+endif()
+
 if(NOT BUILD_METALIBS)
   install(TARGETS p3gobj
     EXPORT Core COMPONENT Core

+ 6 - 1
panda/src/mathutil/CMakeLists.txt

@@ -63,9 +63,14 @@ set(P3MATHUTIL_SOURCES
 composite_sources(p3mathutil P3MATHUTIL_SOURCES)
 add_component_library(p3mathutil SYMBOL BUILDING_PANDA_MATHUTIL
   ${P3MATHUTIL_HEADERS} ${P3MATHUTIL_SOURCES})
-target_link_libraries(p3mathutil p3event PKG::FFTW)
+target_link_libraries(p3mathutil p3event
+  PKG::FFTW)
 target_interrogate(p3mathutil ALL)
 
+if(HAVE_FFTW)
+  target_compile_definitions(p3mathutil PRIVATE HAVE_FFTW)
+endif()
+
 if(NOT BUILD_METALIBS)
   install(TARGETS p3mathutil
     EXPORT Core COMPONENT Core

+ 8 - 0
panda/src/pipeline/CMakeLists.txt

@@ -125,6 +125,14 @@ target_link_libraries(p3pipeline pandaexpress
   PKG::THREADS)
 target_interrogate(p3pipeline ALL EXTENSIONS ${P3PIPELINE_IGATEEXT})
 
+if(PHAVE_UCONTEXT_H)
+  target_compile_definitions(p3pipeline PRIVATE PHAVE_UCONTEXT_H)
+endif()
+
+if(OS_SIMPLE_THREADS)
+  target_compile_definitions(p3pipeline PRIVATE OS_SIMPLE_THREADS)
+endif()
+
 if(NOT BUILD_METALIBS)
   install(TARGETS p3pipeline
     EXPORT Core COMPONENT Core

+ 4 - 0
panda/src/text/CMakeLists.txt

@@ -43,6 +43,10 @@ if(HAVE_FREETYPE)
 endif()
 target_interrogate(p3text ALL)
 
+if(HAVE_HARFBUZZ)
+  target_compile_definitions(p3text PRIVATE HAVE_HARFBUZZ)
+endif()
+
 if(NOT BUILD_METALIBS)
   install(TARGETS p3text
     EXPORT Core COMPONENT Core

+ 4 - 0
panda/src/vision/CMakeLists.txt

@@ -39,6 +39,10 @@ elseif(OPENCV_VER_23)
   set_target_properties(p3vision PROPERTIES COMPILE_DEFINITIONS "OPENCV_VER_23")
 endif()
 
+if(HAVE_FFMPEG)
+  target_compile_definitions(p3vision PRIVATE HAVE_FFMPEG)
+endif()
+
 install(TARGETS p3vision
   EXPORT Vision COMPONENT Vision
   DESTINATION lib

+ 4 - 0
panda/src/windisplay/CMakeLists.txt

@@ -20,6 +20,10 @@ add_component_library(p3windisplay SYMBOL BUILDING_PANDAWIN
   ${P3WINDISPLAY_HEADERS} ${P3WINDISPLAY_SOURCES})
 target_link_libraries(p3windisplay panda User32.lib Imm32.lib)
 
+if(HAVE_DX9)
+  target_compile_definitions(p3windisplay PRIVATE HAVE_DX9)
+endif()
+
 if(NOT BUILD_METALIBS)
   install(TARGETS p3windisplay
     EXPORT Core COMPONENT Core

+ 4 - 0
pandatool/src/bam/CMakeLists.txt

@@ -8,6 +8,10 @@ if(HAVE_EGG)
   target_link_libraries(egg2bam p3eggbase p3progbase panda)
   install(TARGETS egg2bam EXPORT Tools COMPONENT Tools DESTINATION bin)
 
+  if(HAVE_SQUISH)
+    target_compile_definitions(egg2bam PRIVATE HAVE_SQUISH)
+  endif()
+
   add_executable(bam2egg bamToEgg.cxx bamToEgg.h)
   target_link_libraries(bam2egg p3converter p3eggbase p3progbase panda)
   install(TARGETS bam2egg EXPORT Tools COMPONENT Tools DESTINATION bin)

+ 4 - 0
pandatool/src/progbase/CMakeLists.txt

@@ -14,5 +14,9 @@ composite_sources(p3progbase P3PROGBASE_SOURCES)
 add_library(p3progbase STATIC ${P3PROGBASE_HEADERS} ${P3PROGBASE_SOURCES})
 target_link_libraries(p3progbase p3pandatoolbase panda PKG::ZLIB)
 
+if(IOCTL_TERMINAL_WIDTH)
+  target_compile_definitions(p3progbase PRIVATE IOCTL_TERMINAL_WIDTH)
+endif()
+
 # This is only needed for binaries in the pandatool package. It is not useful
 # for user applications, so it is not installed.

+ 1 - 0
pandatool/src/ptloader/CMakeLists.txt

@@ -21,6 +21,7 @@ target_link_libraries(p3ptloader PRIVATE
 
 if(HAVE_FCOLLADA)
   target_link_libraries(p3ptloader PRIVATE p3daeegg)
+  target_compile_definitions(p3ptloader PRIVATE HAVE_FCOLLADA)
 endif()
 
 install(TARGETS p3ptloader EXPORT Tools COMPONENT Tools DESTINATION ${MODULE_DESTINATION})