From 00e403b89c659b31efb036cc5989799ddaaadf5c Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 5 Aug 2023 20:59:43 +0800 Subject: [PATCH] fix cmake BUILD_SHARED_LIBS we should make the library type implicit, so users can decide whether or not to build shared libraries. --- CMakeLists.txt | 12 ++++-------- src/collider/CMakeLists.txt | 2 +- src/cross_section/CMakeLists.txt | 2 +- src/polygon/CMakeLists.txt | 2 +- src/third_party/graphlite/CMakeLists.txt | 2 +- src/utilities/CMakeLists.txt | 3 ++- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44006954a..fe6f37a90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,9 +32,12 @@ if(EMSCRIPTEN) message("Building for Emscripten") set(MANIFOLD_FLAGS -fexceptions -D_LIBCUDACXX_HAS_THREAD_API_EXTERNAL -D_LIBCUDACXX_HAS_THREAD_API_CUDA) set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} -sALLOW_MEMORY_GROWTH=1) + set(MANIFOLD_PYBIND OFF) endif() -option(PYBIND11_FINDPYTHON "Enable PyBind to perform FindPython for you" ON) +if(MANIFOLD_PYBIND) +find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) +endif() option(BUILD_TEST_CGAL "Build CGAL performance comparisons" OFF) @@ -42,13 +45,6 @@ option(BUILD_SHARED_LIBS "Build dynamic/shared libraries" OFF) set(PYBIND11_DIR ${PROJECT_SOURCE_DIR}/bindings/python/third_party/pybind11) set(THRUST_INC_DIR ${PROJECT_SOURCE_DIR}/src/third_party/thrust) -if(BUILD_SHARED_LIBS OR MANIFOLD_CBIND) - # Allow shared libraries to be relocatable (add Place Independent Code flag). - # Also include when statically linking C bindings to avoid issues with bundling - # artefacts in host languages using them for FFI. - add_compile_options(-fPIC) -endif() - if(MANIFOLD_USE_CUDA) enable_language(CUDA) find_package(CUDA REQUIRED) diff --git a/src/collider/CMakeLists.txt b/src/collider/CMakeLists.txt index 8cb298d6e..73682672a 100644 --- a/src/collider/CMakeLists.txt +++ b/src/collider/CMakeLists.txt @@ -15,7 +15,7 @@ project (collider) file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp) -add_library(${PROJECT_NAME} OBJECT ${SOURCE_FILES}) +add_library(${PROJECT_NAME} ${SOURCE_FILES}) if(MANIFOLD_USE_CUDA) set_source_files_properties(${SOURCE_FILES} PROPERTIES LANGUAGE CUDA) diff --git a/src/cross_section/CMakeLists.txt b/src/cross_section/CMakeLists.txt index e7eddae5f..4f9c28d00 100644 --- a/src/cross_section/CMakeLists.txt +++ b/src/cross_section/CMakeLists.txt @@ -15,7 +15,7 @@ project (cross_section) file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp) -add_library(${PROJECT_NAME} OBJECT ${SOURCE_FILES}) +add_library(${PROJECT_NAME} ${SOURCE_FILES}) target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include diff --git a/src/polygon/CMakeLists.txt b/src/polygon/CMakeLists.txt index d24497490..1d2cbe6af 100644 --- a/src/polygon/CMakeLists.txt +++ b/src/polygon/CMakeLists.txt @@ -15,7 +15,7 @@ project (polygon) file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp) -add_library(${PROJECT_NAME} OBJECT ${SOURCE_FILES}) +add_library(${PROJECT_NAME} ${SOURCE_FILES}) target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include diff --git a/src/third_party/graphlite/CMakeLists.txt b/src/third_party/graphlite/CMakeLists.txt index d7b080db1..30d67b005 100644 --- a/src/third_party/graphlite/CMakeLists.txt +++ b/src/third_party/graphlite/CMakeLists.txt @@ -1,6 +1,6 @@ project (graphlite) -add_library(${PROJECT_NAME} OBJECT src/connected_components.cpp) +add_library(${PROJECT_NAME} src/connected_components.cpp) target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include diff --git a/src/utilities/CMakeLists.txt b/src/utilities/CMakeLists.txt index e04a55e31..1d79a401b 100644 --- a/src/utilities/CMakeLists.txt +++ b/src/utilities/CMakeLists.txt @@ -15,7 +15,7 @@ project(utilities) file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp) -add_library(${PROJECT_NAME} OBJECT ${SOURCE_FILES}) +add_library(${PROJECT_NAME} ${SOURCE_FILES}) message("CUDA Support: ${MANIFOLD_USE_CUDA}") message("Parallel Backend: ${MANIFOLD_PAR}") @@ -37,6 +37,7 @@ elseif(MANIFOLD_PAR STREQUAL "TBB") message(STATUS "tbb not found, downloading from source") include(FetchContent) set(TBB_TEST OFF CACHE INTERNAL "" FORCE) + set(TBB_STRICT OFF CACHE INTERNAL "" FORCE) FetchContent_Declare(TBB GIT_REPOSITORY https://github.com/oneapi-src/oneTBB.git # versions afterward forces -D_FORTIFY_SOURCE=2