Browse Source

CMake: First batch of improvements per review

Addressing feedback per @rdb in GitHub #717
Sam Edwards 6 years ago
parent
commit
5654e64645
6 changed files with 34 additions and 27 deletions
  1. 6 4
      CMakeLists.txt
  2. 1 1
      cmake/install/Panda3DConfig.cmake
  3. 1 1
      dtool/CompilerFlags.cmake
  4. 0 15
      dtool/Config.cmake
  5. 2 6
      dtool/Package.cmake
  6. 24 0
      panda/CMakeLists.txt

+ 6 - 4
CMakeLists.txt

@@ -9,10 +9,12 @@ if(CMAKE_VERSION VERSION_GREATER "3.12" OR POLICY CMP0074)
 endif()
 
 # Figure out the version
-file(STRINGS "setup.cfg" _version REGEX "^version = ")
-string(REGEX REPLACE "^.*= " "" _version "${_version}")
+set(_s "[\\t ]*") # CMake doesn't support \s*
+file(STRINGS "setup.cfg" _version REGEX "^version${_s}=${_s}")
+string(REGEX REPLACE "^.*=${_s}" "" _version "${_version}")
 project(Panda3D VERSION ${_version})
 unset(_version)
+unset(_s)
 
 enable_testing()
 
@@ -52,8 +54,8 @@ include(RunPzip)            # Defines run_pzip function
 include(Versioning)         # Hooks 'add_library' to apply VERSION/SOVERSION
 
 # Determine which trees to build.
-option(BUILD_DTOOL  "Build the dtool source tree." ON)
-option(BUILD_PANDA  "Build the panda source tree." ON)
+option(BUILD_DTOOL "Build the dtool source tree." ON)
+option(BUILD_PANDA "Build the panda source tree." ON)
 option(BUILD_DIRECT "Build the direct source tree." ON)
 option(BUILD_PANDATOOL "Build the pandatool source tree." ON)
 option(BUILD_CONTRIB "Build the contrib source tree." ON)

+ 1 - 1
cmake/install/Panda3DConfig.cmake

@@ -80,7 +80,7 @@
 #
 #   FMOD      - Support for FMOD audio output.
 #
-#               Panda3D::OpenAL::p3fmod_audio
+#               Panda3D::FMOD::p3fmod_audio
 #
 #
 #   OpenGL    - Support for OpenGL rendering.

+ 1 - 1
dtool/CompilerFlags.cmake

@@ -103,7 +103,7 @@ if(NOT "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
   set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Wno-unused-variable")
 
   if(MSVC)
-    # Clang behaving as MSVC`
+    # Clang behaving as MSVC
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-command-line-argument")
     set(CMAKE_CXX_FLAGS
       "${CMAKE_CXX_FLAGS} -Wno-microsoft-template -Wno-unused-command-line-argument")

+ 0 - 15
dtool/Config.cmake

@@ -254,21 +254,6 @@ mark_as_advanced(DEFAULT_PRC_DIR PRC_DIR_ENVVARS PRC_PATH_ENVVARS
 # remaining variables are of general interest to everyone.
 #
 
-
-option(HAVE_P3D_RTDIST
-  "You may define this to build or develop the Panda3D rtdist,
-the environment packaged up for distribution with the plugin."
-  OFF)
-
-if(HAVE_P3D_RTDIST)
-  set(PANDA_PACKAGE_VERSION "local_dev" CACHE STRING "")
-  set(PANDA_PACKAGE_HOST_URL "http://localhost/" CACHE STRING "")
-endif()
-
-mark_as_advanced(HAVE_P3D_RTDIST PANDA_PACKAGE_VERSION PANDA_PACKAGE_HOST)
-
-
-
 # The following options relate to interrogate, the tool that is
 # used to generate bindings for non-C++ languages.
 

+ 2 - 6
dtool/Package.cmake

@@ -149,9 +149,6 @@ if(CMAKE_VERSION VERSION_LESS "3.15")
       # macOS requires this explicit flag on the linker command line to allow the
       # references to the Python symbols to resolve at dynamic link time
       string(APPEND CMAKE_MODULE_LINKER_FLAGS " -undefined dynamic_lookup")
-      # TODO: p3dcparser contains some direct Python references; get rid of
-      # this once that's gone
-      string(APPEND CMAKE_SHARED_LINKER_FLAGS " -undefined dynamic_lookup")
 
     endif()
 
@@ -263,7 +260,7 @@ package_status(ZLIB "zlib")
 # JPEG
 find_package(JPEG QUIET)
 
-package_option(JPEG DEFAULT ON "Enable support for loading .jpg images.")
+package_option(JPEG "Enable support for loading .jpg images.")
 
 package_status(JPEG "libjpeg")
 
@@ -271,7 +268,6 @@ package_status(JPEG "libjpeg")
 find_package(PNG QUIET)
 
 package_option(PNG
-  DEFAULT ON
   "Enable support for loading .png images."
   IMPORTED_AS PNG::PNG)
 
@@ -344,7 +340,7 @@ package_status(FCOLLADA "FCollada")
 find_package(Eigen3 QUIET)
 
 package_option(EIGEN
-  "Enables experimental support for the Eigen linear algebra library.
+  "Enables use of 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

+ 24 - 0
panda/CMakeLists.txt

@@ -106,6 +106,30 @@ endif()
 if(INTERROGATE_PYTHON_INTERFACE)
   add_python_module(panda3d.core ${CORE_MODULE_COMPONENTS} LINK panda)
 
+  # Generate our __init__.py
+  if(WIN32)
+    file(READ "${PROJECT_SOURCE_DIR}/cmake/templates/win32_python/__init__.py" win32_init)
+  else()
+    set(win32_init "")
+  endif()
+
+  file(WRITE "${PROJECT_BINARY_DIR}/panda3d/__init__.py"
+    "\"Python bindings for the Panda3D libraries\"
+
+__version__ = '${PROJECT_VERSION}'
+
+if __debug__:
+    import sys
+    if sys.version_info < (3, 0):
+        sys.stderr.write('''\\
+WARNING: Python 2.7 will reach EOL after December 31, 2019.
+To suppress this warning, upgrade to Python 3.
+''')
+        sys.stdout.flush()
+    del sys
+
+${win32_init}")
+
   if(BUILD_SHARED_LIBS)
     install_python_package(panda3d ARCH)
   endif()