Browse Source

CMake: Build Python binary modules as MODULE, never SHARED

Sam Edwards 7 years ago
parent
commit
cfd603bb8d
2 changed files with 13 additions and 3 deletions
  1. 5 1
      cmake/macros/Interrogate.cmake
  2. 8 2
      dtool/metalibs/dtoolconfig/CMakeLists.txt

+ 5 - 1
cmake/macros/Interrogate.cmake

@@ -286,7 +286,11 @@ function(add_python_module module)
       COMMENT "Generating module ${module}"
     )
 
-    add_library(${module} "${module}_module.cxx" ${sources})
+    if(BUILD_SHARED_LIBS)
+      add_library(${module} MODULE "${module}_module.cxx" ${sources})
+    else()
+      add_library(${module} STATIC "${module}_module.cxx" ${sources})
+    endif()
     target_link_libraries(${module}
       ${link_targets} ${PYTHON_LIBRARIES} p3interrogatedb)
 

+ 8 - 2
dtool/metalibs/dtoolconfig/CMakeLists.txt

@@ -1,9 +1,15 @@
 add_definitions(-DBUILDING_DTOOLCONFIG)
 
+if(BUILD_SHARED_LIBS)
+  set(libtype MODULE)
+else()
+  set(libtype STATIC)
+endif()
+
 if(HAVE_PYTHON)
-  add_library(p3dtoolconfig dtoolconfig.cxx pydtool.cxx)
+  add_library(p3dtoolconfig ${libtype} dtoolconfig.cxx pydtool.cxx)
 else()
-  add_library(p3dtoolconfig dtoolconfig.cxx)
+  add_library(p3dtoolconfig ${libtype} dtoolconfig.cxx)
 endif()
 
 target_use_packages(p3dtoolconfig PYTHON)