Browse Source

Have package_option automatically generate option library targets instead of checking in every instance they're used.

kestred 12 years ago
parent
commit
b04ebdda98

+ 8 - 5
cmake/macros/PackageConfig.cmake

@@ -73,9 +73,12 @@ function(package_option name)
 
 
   # Create the option.
   # Create the option.
   option("HAVE_${name}" "${cache_string}" "${default}")
   option("HAVE_${name}" "${cache_string}" "${default}")
-  if(NOT HAVE_${name})
-    unset(${name}_LIBRARY)
-    unset(${name}_LIBRARIES)
+  if(HAVE_${name})
+    set(_${name}_LIBRARY ${${name}_LIBRARY} CACHE INTERNAL "<Internal>")
+    set(_${name}_LIBRARIES ${${name}_LIBRARIES} CACHE INTERNAL "<Internal>")
+  else()
+    unset(_${name}_LIBRARY CACHE)
+    unset(_${name}_LIBRARIES CACHE)
   endif()
   endif()
 endfunction()
 endfunction()
 
 
@@ -93,9 +96,9 @@ macro(target_use_packages target)
     if(HAVE_${lib})
     if(HAVE_${lib})
       target_include_directories("${target}" PUBLIC "${${lib}_INCLUDE_DIRS};${${lib}_INCLUDE_DIR}")
       target_include_directories("${target}" PUBLIC "${${lib}_INCLUDE_DIRS};${${lib}_INCLUDE_DIR}")
       if(${lib}_LIBRARIES)
       if(${lib}_LIBRARIES)
-        target_link_libraries("${target}" ${${lib}_LIBRARIES})
+        target_link_libraries("${target}" ${_${lib}_LIBRARIES})
       else()
       else()
-        target_link_libraries("${target}" ${${lib}_LIBRARY})
+        target_link_libraries("${target}" ${_${lib}_LIBRARY})
       endif()
       endif()
     endif()
     endif()
   endforeach(lib)
   endforeach(lib)

+ 1 - 1
dtool/metalibs/dtoolconfig/CMakeLists.txt

@@ -2,7 +2,7 @@ add_definitions(-DBUILDING_DTOOLCONFIG)
 
 
 if(HAVE_PYTHON)
 if(HAVE_PYTHON)
   add_library(p3dtoolconfig dtoolconfig.cxx pydtool.cxx)
   add_library(p3dtoolconfig dtoolconfig.cxx pydtool.cxx)
-  target_link_libraries(p3dtoolconfig ${PYTHON_LIBRARIES})
+  target_link_libraries(p3dtoolconfig ${_PYTHON_LIBRARIES})
 else()
 else()
   add_library(p3dtoolconfig dtoolconfig.cxx)
   add_library(p3dtoolconfig dtoolconfig.cxx)
 endif()
 endif()

+ 1 - 1
dtool/src/interrogate/CMakeLists.txt

@@ -50,4 +50,4 @@ composite_sources(interrogate INTERROGATE_SOURCES)
 add_executable(interrogate ${INTERROGATE_HEADERS} ${INTERROGATE_SOURCES})
 add_executable(interrogate ${INTERROGATE_HEADERS} ${INTERROGATE_SOURCES})
 target_link_libraries(interrogate
 target_link_libraries(interrogate
 	p3cppParser p3interrogatedb p3dconfig p3prc p3dtoolutil p3dtoolbase
 	p3cppParser p3interrogatedb p3dconfig p3prc p3dtoolutil p3dtoolbase
-	p3pystub ${OPENSSL_LIBRARIES})
+	p3pystub ${_OPENSSL_LIBRARIES})

+ 1 - 1
dtool/src/prc/CMakeLists.txt

@@ -65,4 +65,4 @@ set(P3PRC_SOURCES
 composite_sources(p3prc P3PRC_SOURCES)
 composite_sources(p3prc P3PRC_SOURCES)
 
 
 add_library(p3prc ${P3PRC_HEADERS} ${P3PRC_SOURCES})
 add_library(p3prc ${P3PRC_HEADERS} ${P3PRC_SOURCES})
-target_link_libraries(p3prc p3dtoolutil p3dtoolbase ${OPENSSL_LIBRARIES})
+target_link_libraries(p3prc p3dtoolutil p3dtoolbase ${_OPENSSL_LIBRARIES})

+ 2 - 1
panda/src/express/CMakeLists.txt

@@ -125,9 +125,10 @@ set(P3EXPRESS_SOURCES
 
 
 composite_sources(p3express P3EXPRESS_SOURCES)
 composite_sources(p3express P3EXPRESS_SOURCES)
 
 
+message("TAR ${_TAR_LIBRARY}")
 add_library(p3express ${P3EXPRESS_SOURCES} ${P3EXPRESS_HEADERS})
 add_library(p3express ${P3EXPRESS_SOURCES} ${P3EXPRESS_HEADERS})
 target_link_libraries(p3express p3pandabase p3dtool p3dtoolconfig
 target_link_libraries(p3express p3pandabase p3dtool p3dtoolconfig
-  ${TAR_LIBRARY})
+  ${_TAR_LIBRARY})
 target_interrogate(p3express ALL)
 target_interrogate(p3express ALL)
 
 
 #add_executable(p3expressTestTypes test_types.cxx)
 #add_executable(p3expressTestTypes test_types.cxx)

+ 1 - 1
panda/src/glgsg/CMakeLists.txt

@@ -11,6 +11,6 @@ if(HAVE_GL)
   composite_sources(p3glgsg P3GLGSG_SOURCES)
   composite_sources(p3glgsg P3GLGSG_SOURCES)
   add_library(p3glgsg ${P3GLGSG_HEADERS} ${P3GLGSG_SOURCES})
   add_library(p3glgsg ${P3GLGSG_HEADERS} ${P3GLGSG_SOURCES})
   target_link_libraries(p3glgsg p3glstuff p3display
   target_link_libraries(p3glgsg p3glstuff p3display
-    ${OPENGL_LIBRARIES} ${CG_LIBRARIES})
+    ${OPENGL_LIBRARIES} ${_CG_LIBRARIES})
   target_interrogate(p3glgsg ALL)
   target_interrogate(p3glgsg ALL)
 endif()
 endif()

+ 1 - 1
panda/src/gobj/CMakeLists.txt

@@ -144,7 +144,7 @@ set(P3GOBJ_SOURCES
 composite_sources(p3gobj P3GOBJ_SOURCES)
 composite_sources(p3gobj P3GOBJ_SOURCES)
 add_library(p3gobj ${P3GOBJ_HEADERS} ${P3GOBJ_SOURCES})
 add_library(p3gobj ${P3GOBJ_HEADERS} ${P3GOBJ_SOURCES})
 target_link_libraries(p3gobj p3gsgbase p3pnmimage
 target_link_libraries(p3gobj p3gsgbase p3pnmimage
-  ${ZLIB_LIBRARIES} ${SQUISH_LIBRARY})
+  ${_ZLIB_LIBRARIES} ${_SQUISH_LIBRARY})
 target_interrogate(p3gobj ALL)
 target_interrogate(p3gobj ALL)
 
 
 #begin test_bin_target
 #begin test_bin_target

+ 2 - 23
panda/src/pnmimagetypes/CMakeLists.txt

@@ -26,29 +26,8 @@ set(P3PNMIMAGETYPES_SOURCES
   pnmFileTypeTGA.cxx
   pnmFileTypeTGA.cxx
 )
 )
 
 
-# We aggregate the PNMIMAGETYPES libraries depending on which image formats are
-# compiled in.
-unset(PNMIMAGETYPES_LINK_LIBRARIES)
-
-if(HAVE_JPEG)
-  set(PNMIMAGETYPES_LINK_LIBRARIES
-    ${PNMIMAGETYPES_LINK_LIBRARIES}
-    ${JPEG_LIBRARIES})
-endif()
-
-if(HAVE_TIFF)
-  set(PNMIMAGETYPES_LINK_LIBRARIES
-    ${PNMIMAGETYPES_LINK_LIBRARIES}
-    ${TIFF_LIBRARIES})
-endif()
-
-if(HAVE_PNG)
-  set(PNMIMAGETYPES_LINK_LIBRARIES
-    ${PNMIMAGETYPES_LINK_LIBRARIES}
-    ${PNG_LIBRARIES})
-endif()
-
 composite_sources(p3pnmimagetypes P3PNMIMAGETYPES_SOURCES)
 composite_sources(p3pnmimagetypes P3PNMIMAGETYPES_SOURCES)
 add_library(p3pnmimagetypes ${P3PNMIMAGETYPES_HEADERS} ${P3PNMIMAGETYPES_SOURCES})
 add_library(p3pnmimagetypes ${P3PNMIMAGETYPES_HEADERS} ${P3PNMIMAGETYPES_SOURCES})
-target_link_libraries(p3pnmimagetypes p3pnmimage ${PNMIMAGETYPES_LINK_LIBRARIES})
+target_link_libraries(p3pnmimagetypes p3pnmimage ${_JPEG_LIBRARIES}
+  ${_TIFF_LIBRARIES} ${_PNG_LIBRARIES})
 target_interrogate(p3pnmimagetypes ALL)
 target_interrogate(p3pnmimagetypes ALL)

+ 1 - 1
panda/src/pnmtext/CMakeLists.txt

@@ -15,5 +15,5 @@ set(P3PNMTEXT_SOURCES
 
 
 composite_sources(p3pnmtext P3PNMTEXT_SOURCES)
 composite_sources(p3pnmtext P3PNMTEXT_SOURCES)
 add_library(p3pnmtext ${P3PNMTEXT_SOURCES} ${P3PNMTEXT_HEADERS})
 add_library(p3pnmtext ${P3PNMTEXT_SOURCES} ${P3PNMTEXT_HEADERS})
-target_link_libraries(p3pnmtext p3pnmimage ${FREETYPE_LIBRARIES})
+target_link_libraries(p3pnmtext p3pnmimage ${_FREETYPE_LIBRARIES})
 target_interrogate(p3pnmtext ALL)
 target_interrogate(p3pnmtext ALL)

+ 1 - 1
panda/src/text/CMakeLists.txt

@@ -34,5 +34,5 @@ set(P3TEXT_SOURCES
 
 
 composite_sources(p3text P3TEXT_SOURCES)
 composite_sources(p3text P3TEXT_SOURCES)
 add_library(p3text ${P3TEXT_SOURCES} ${P3TEXT_HEADERS})
 add_library(p3text ${P3TEXT_SOURCES} ${P3TEXT_HEADERS})
-target_link_libraries(p3text p3pnmtext p3parametrics ${FREETYPE_LIBRARIES})
+target_link_libraries(p3text p3pnmtext p3parametrics ${_FREETYPE_LIBRARIES})
 target_interrogate(p3text ALL)
 target_interrogate(p3text ALL)