Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake changes #1048

Merged
merged 50 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
cc64fe1
enable emscripten build with tbb enabled
pca006132 Nov 15, 2024
595b633
nix: fix emscripten build, add tbb build
pca006132 Nov 15, 2024
7032c4b
browser
pca006132 Nov 15, 2024
568ebbf
fix python build
pca006132 Nov 15, 2024
8e71a37
minor
pca006132 Nov 15, 2024
ae78dd1
no parallel sdf for js
pca006132 Nov 15, 2024
e5960b2
disable test for emscripten-tbb
pca006132 Nov 15, 2024
27204cd
Merge branch 'master' into emscripten-tbb
pca006132 Nov 16, 2024
162ca3c
add cache for nix python build
pca006132 Nov 16, 2024
b3bed73
cmake changes
pca006132 Nov 16, 2024
8a372bf
fix
pca006132 Nov 16, 2024
590fc5c
update
pca006132 Nov 16, 2024
b15c7b3
update
pca006132 Nov 16, 2024
fcf4e22
Merge remote-tracking branch 'upstream/emscripten-tbb' into cmake-ref…
pca006132 Nov 16, 2024
8788bff
update
pca006132 Nov 16, 2024
b880c7b
update
pca006132 Nov 16, 2024
deab097
move python dependency handling
pca006132 Nov 16, 2024
9d6892b
more changes
pca006132 Nov 16, 2024
4eca995
format
pca006132 Nov 16, 2024
ddfc19f
fix broken format
pca006132 Nov 16, 2024
f5dafa9
fix
pca006132 Nov 16, 2024
e553566
simplify
pca006132 Nov 16, 2024
fa62dc2
allow emscripten with cbind
pca006132 Nov 16, 2024
abc019e
build fetched dependencies as static libs
pca006132 Nov 16, 2024
58e8be8
fix static build
pca006132 Nov 16, 2024
0ca6a6a
fix rebuild
pca006132 Nov 16, 2024
5b6a9df
fix extras
pca006132 Nov 16, 2024
5bdd834
Merge remote-tracking branch 'upstream/master' into cmake-refactor
pca006132 Nov 16, 2024
d8e8c4f
remove parallel.h from public API
pca006132 Nov 16, 2024
f6616a0
update tests
pca006132 Nov 16, 2024
fdfdf73
make dependencies private
pca006132 Nov 16, 2024
c199560
move parallel.h
pca006132 Nov 16, 2024
1c9b86f
missing utils.h change
pca006132 Nov 16, 2024
385e89a
fix
pca006132 Nov 16, 2024
4143509
fix...
pca006132 Nov 17, 2024
7e0a9df
fix wasm tbb
pca006132 Nov 17, 2024
916c3b2
add more cmake consumer tests
pca006132 Nov 17, 2024
21ed208
fix consumer
pca006132 Nov 17, 2024
2e8a96c
add rpath
pca006132 Nov 17, 2024
f2fd36d
Revert "add rpath"
pca006132 Nov 17, 2024
14cc182
rpath specific to macos
pca006132 Nov 17, 2024
271b95b
use override
pca006132 Nov 17, 2024
4fdba84
forgot to set rpath...
pca006132 Nov 17, 2024
f02edbb
remove #1045 related changes
pca006132 Nov 17, 2024
253333c
integrate #1052
pca006132 Nov 17, 2024
73359da
allow version override
pca006132 Nov 17, 2024
3370652
minor improvements
pca006132 Nov 17, 2024
bc7d3cd
msvc changes
pca006132 Nov 17, 2024
21479c9
Merge branch 'master' of github.com:elalish/manifold into cmake-refactor
elalish Nov 17, 2024
5979b06
fix typo
elalish Nov 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
283 changes: 52 additions & 231 deletions CMakeLists.txt

Large diffs are not rendered by default.

22 changes: 18 additions & 4 deletions bindings/c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# this is a shared library for FFI bindings
# Copyright 2024 The Manifold Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
Expand All @@ -7,13 +20,15 @@ include_directories(

add_library(
manifoldc
SHARED
manifoldc.cpp
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking maybe rust users will want to build the library statically and link it, so we shouldn't force this as a shared library.

conv.cpp
box.cpp
cross.cpp
rect.cpp
)
add_library(manifold::manifoldc ALIAS manifoldc)
set_property(TARGET manifoldc PROPERTY VERSION "${MANIFOLD_VERSION}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Namespace alias so users can just do manifold::manifold/manifold::manifoldc when they use our library, regardless of whether it is a system install or subdirectory.

set_property(TARGET manifoldc PROPERTY SOVERSION ${MANIFOLD_VERSION_MAJOR})

if(MSVC)
set_target_properties(manifoldc PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
Expand All @@ -38,10 +53,9 @@ target_include_directories(
manifoldc
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/bindings/c/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_compile_options(manifoldc PRIVATE ${MANIFOLD_FLAGS})
target_compile_features(manifoldc PRIVATE cxx_std_17)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we have the global CMAKE_CXX_STANDARD, this is now redundant.

install(TARGETS manifoldc EXPORT manifoldTargets)
install(
Expand Down
16 changes: 7 additions & 9 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ if(NOT MANIFOLD_PYBIND)
return()
endif()

project(python)

if(Python_VERSION VERSION_LESS 3.12)
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
else()
Expand Down Expand Up @@ -46,8 +44,8 @@ if(NB_VERSION VERSION_GREATER_EQUAL 2.0.0)
)
find_package(nanobind CONFIG REQUIRED)
else()
message(STATUS "nanobind not found, downloading from source")
include(FetchContent)
logmissingdep("nanobind" , "MANIFOLD_PYBIND")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure we will not do download when MANIFOLD_DOWNLOAD is disabled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and I thought of moving this to cmake/manifoldDeps.cmake, but not sure if that is the best thing to do...

FetchContent_Declare(
nanobind
GIT_REPOSITORY https://github.com/wjakob/nanobind.git
Expand Down Expand Up @@ -91,12 +89,12 @@ message(Python_EXECUTABLE = ${Python_EXECUTABLE})
# ideally we should generate a dependency file from python...
set(
DOCSTRING_DEPS
${CMAKE_SOURCE_DIR}/src/manifold.cpp
${CMAKE_SOURCE_DIR}/src/constructors.cpp
${CMAKE_SOURCE_DIR}/src/sort.cpp
${CMAKE_SOURCE_DIR}/src/cross_section/cross_section.cpp
${CMAKE_SOURCE_DIR}/src/polygon.cpp
${CMAKE_SOURCE_DIR}/include/manifold/common.h
${PROJECT_SOURCE_DIR}/src/manifold.cpp
${PROJECT_SOURCE_DIR}/src/constructors.cpp
${PROJECT_SOURCE_DIR}/src/sort.cpp
${PROJECT_SOURCE_DIR}/src/cross_section/cross_section.cpp
${PROJECT_SOURCE_DIR}/src/polygon.cpp
${PROJECT_SOURCE_DIR}/include/manifold/common.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch. Using CMAKE_SOURCE_DIR is a habit I have left from the old days, looks like PROJECT_SOURCE_DIR is probably what one would want most of the time.

${CMAKE_CURRENT_SOURCE_DIR}/gen_docs.py
${CMAKE_CURRENT_SOURCE_DIR}/docstring_override.txt
)
Expand Down
16 changes: 3 additions & 13 deletions bindings/wasm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,18 @@ add_custom_target(
DEPENDS manifoldjs ${CMAKE_CURRENT_SOURCE_DIR}/manifold*.d.ts
)

# copy WASM build back here for publishing to npm
add_custom_command(
TARGET js_deps
POST_BUILD
# copy WASM build back here for publishing to npm
COMMAND
${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/manifold.*
${CMAKE_CURRENT_SOURCE_DIR}
)

# copy WASM build and TS declarations for Vite to package into ManifoldCAD.org
add_custom_command(
TARGET js_deps
POST_BUILD
# copy WASM build and TS declarations for Vite to package into ManifoldCAD.org
COMMAND
${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/manifold*
${CMAKE_CURRENT_SOURCE_DIR}/examples/built/
)

# copy TS declarations to public so they can be accessed by our editor
add_custom_command(
TARGET js_deps
POST_BUILD
# copy TS declarations to public so they can be accessed by our editor
COMMAND
${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/manifold*.d.ts
${CMAKE_CURRENT_SOURCE_DIR}/examples/public/
Expand Down
63 changes: 63 additions & 0 deletions cmake/info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2024 The Manifold Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# configuration summary, idea from openscad
# https://github.com/openscad/openscad/blob/master/cmake/Modules/info.cmake
message(STATUS "====================================")
message(STATUS "Manifold Build Configuration Summary")
message(STATUS "====================================")
message(STATUS " ")
if(MXECROSS)
message(STATUS "Environment: MXE")
elseif(APPLE)
message(STATUS "Environment: macOS")
elseif(WIN32)
if(MINGW)
message(STATUS "Environment: msys2")
else()
message(STATUS "Environment: Windows")
endif()
elseif(LINUX)
message(STATUS "Environment: Linux")
elseif(UNIX)
message(STATUS "Environment: Unknown Unix")
else()
message(STATUS "Environment: Unknown")
endif()
message(STATUS " ")
message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}")
message(STATUS "CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}")
message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
message(STATUS "CPACK_CMAKE_GENERATOR: ${CPACK_CMAKE_GENERATOR}")
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "CMAKE_CXX_COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}")
if(APPLE)
message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
message(STATUS "CMAKE_OSX_ARCHITECTURES: ${CMAKE_OSX_ARCHITECTURES}")
endif()
message(STATUS "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
message(STATUS " ")
message(STATUS "MANIFOLD_PAR: ${MANIFOLD_PAR}")
message(STATUS "MANIFOLD_CROSS_SECTION: ${MANIFOLD_CROSS_SECTION}")
message(STATUS "MANIFOLD_EXPORT: ${MANIFOLD_EXPORT}")
message(STATUS "MANIFOLD_TEST: ${MANIFOLD_TEST}")
message(STATUS "MANIFOLD_FUZZ: ${MANIFOLD_FUZZ}")
message(STATUS "MANIFOLD_DEBUG: ${MANIFOLD_DEBUG}")
message(STATUS "MANIFOLD_CBIND: ${MANIFOLD_CBIND}")
message(STATUS "MANIFOLD_PYBIND: ${MANIFOLD_PYBIND}")
message(STATUS "MANIFOLD_JSBIND: ${MANIFOLD_JSBIND}")
message(STATUS "MANIFOLD_FLAGS: ${MANIFOLD_FLAGS}")
message(STATUS " ")
File renamed without changes.
File renamed without changes.
140 changes: 140 additions & 0 deletions cmake/manifoldDeps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Copyright 2024 The Manifold Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include(FetchContent)

function(logmissingdep PKG)
# if this is already in FETCHCONTENT_SOURCE_DIR_X, we don't have to
# download...
if(DEFINED FETCHCONTENT_SOURCE_DIR_${PKG})
return()
endif()
if(NOT MANIFOLD_DOWNLOADS)
if(ARGC EQUAL 3)
set(MSG "${ARGV2} enabled, but ${PKG} was not found ")
string(APPEND MSG "and dependency downloading is disabled. ")
else()
set(MSG "${PKG} not found, and dependency downloading disabled. ")
endif()
string(APPEND MSG "Please install ${PKG} and reconfigure.\n")
message(FATAL_ERROR ${MSG})
else()
message(STATUS "${PKG} not found, downloading from source")
endif()
endfunction()

# If we're building parallel, we need the requisite libraries
if(MANIFOLD_PAR)
find_package(Threads REQUIRED)
find_package(TBB QUIET)
find_package(PkgConfig QUIET)
if(NOT TBB_FOUND AND PKG_CONFIG_FOUND)
pkg_check_modules(TBB tbb)
endif()
if(NOT TBB_FOUND)
logmissingdep("TBB" , "Parallel mode")
set(TBB_TEST OFF CACHE INTERNAL BOOL FORCE)
set(TBB_STRICT OFF CACHE INTERNAL BOOL FORCE)
FetchContent_Declare(
TBB
GIT_REPOSITORY https://github.com/oneapi-src/oneTBB.git
GIT_TAG v2021.11.0
GIT_PROGRESS TRUE
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(TBB)
# note: we do want to install tbb to the user machine when built from
# source
if(NOT EMSCRIPTEN)
install(TARGETS tbb)
endif()
endif()
endif()

# If we're building cross_section, we need Clipper2
if(MANIFOLD_CROSS_SECTION)
find_package(Clipper2 QUIET)
if(NOT Clipper2_FOUND AND PKG_CONFIG_FOUND)
pkg_check_modules(Clipper2 Clipper2)
endif()
if(Clipper2_FOUND)
add_library(Clipper2 SHARED IMPORTED)
set_property(
TARGET Clipper2
PROPERTY IMPORTED_LOCATION ${Clipper2_LINK_LIBRARIES}
)
if(WIN32)
set_property(
TARGET Clipper2
PROPERTY IMPORTED_IMPLIB ${Clipper2_LINK_LIBRARIES}
)
endif()
target_include_directories(Clipper2 INTERFACE ${Clipper2_INCLUDE_DIRS})
else()
logmissingdep("Clipper2" , "cross_section")
set(CLIPPER2_UTILS OFF CACHE INTERNAL BOOL FORCE)
set(CLIPPER2_EXAMPLES OFF CACHE INTERNAL BOOL FORCE)
set(CLIPPER2_TESTS OFF CACHE INTERNAL BOOL FORCE)
set(CLIPPER2_USINGZ OFF CACHE INTERNAL BOOL FORCE)
FetchContent_Declare(
Clipper2
elalish marked this conversation as resolved.
Show resolved Hide resolved
GIT_REPOSITORY https://github.com/AngusJohnson/Clipper2.git
GIT_TAG ff378668baae3570e9d8070aa9eb339bdd5a6aba
GIT_PROGRESS TRUE
SOURCE_SUBDIR CPP
)
FetchContent_MakeAvailable(Clipper2)
if(NOT EMSCRIPTEN)
install(TARGETS Clipper2)
endif()
endif()
endif()

if(TRACY_ENABLE)
logmissingdep("tracy" , "TRACY_ENABLE")
FetchContent_Declare(
tracy
GIT_REPOSITORY https://github.com/wolfpld/tracy.git
GIT_TAG v0.10
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(tracy)
endif()

# If we're supporting mesh I/O, we need assimp
if(MANIFOLD_EXPORT)
find_package(assimp REQUIRED)
endif()

if(MANIFOLD_TEST)
find_package(GTest QUIET)
if(NOT GTest_FOUND)
logmissingdep("GTest" , "MANIFOLD_TEST")
set(gtest_force_shared_crt ON CACHE BOOL FORCE)
# Prevent installation of GTest with your project
set(INSTALL_GTEST OFF CACHE BOOL FORCE)
set(INSTALL_GMOCK OFF CACHE BOOL FORCE)

include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
FIND_PACKAGE_ARGS NAMES GTest gtest
)
FetchContent_MakeAvailable(googletest)
endif()
endif()
5 changes: 0 additions & 5 deletions extras/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,25 @@ endif()
add_executable(perfTest perf_test.cpp)
target_link_libraries(perfTest manifold)
target_compile_options(perfTest PRIVATE ${MANIFOLD_FLAGS})
target_compile_features(perfTest PUBLIC cxx_std_17)

if(MANIFOLD_PAR AND NOT MSVC)
add_executable(stlTest stl_test.cpp)
target_link_libraries(stlTest manifold)
target_compile_options(stlTest PRIVATE ${MANIFOLD_FLAGS})
target_compile_features(stlTest PUBLIC cxx_std_17)
endif()

add_executable(largeSceneTest large_scene_test.cpp)
target_link_libraries(largeSceneTest manifold)
target_compile_options(largeSceneTest PRIVATE ${MANIFOLD_FLAGS})
target_compile_features(largeSceneTest PUBLIC cxx_std_17)

if(MANIFOLD_DEBUG)
add_executable(minimizeTestcase minimize_testcase.cpp)
target_link_libraries(minimizeTestcase manifold)
target_compile_options(minimizeTestcase PRIVATE ${MANIFOLD_FLAGS})
target_compile_features(minimizeTestcase PUBLIC cxx_std_17)
endif()

if(MANIFOLD_EXPORT)
add_executable(convertFile convert_file.cpp)
target_link_libraries(convertFile manifold manifold)
target_compile_options(convertFile PRIVATE ${MANIFOLD_FLAGS})
target_compile_features(convertFile PUBLIC cxx_std_17)
endif()
1 change: 0 additions & 1 deletion samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ target_include_directories(samples PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(samples PUBLIC manifold)

target_compile_options(samples PRIVATE ${MANIFOLD_FLAGS})
target_compile_features(samples PUBLIC cxx_std_17)
Loading
Loading