-
Notifications
You must be signed in to change notification settings - Fork 101
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
cmake changes #1048
Changes from 1 commit
cc64fe1
595b633
7032c4b
568ebbf
8e71a37
ae78dd1
e5960b2
27204cd
162ca3c
b3bed73
8a372bf
590fc5c
b15c7b3
fcf4e22
8788bff
b880c7b
deab097
9d6892b
4eca995
ddfc19f
f5dafa9
e553566
fa62dc2
abc019e
58e8be8
0ca6a6a
5b6a9df
5bdd834
d8e8c4f
f6616a0
fdfdf73
c199560
1c9b86f
385e89a
4143509
7e0a9df
916c3b2
21ed208
2e8a96c
f2fd36d
14cc182
271b95b
4fdba84
f02edbb
253333c
73359da
3370652
bc7d3cd
21479c9
5979b06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
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 | ||
|
@@ -7,13 +20,15 @@ include_directories( | |
|
||
add_library( | ||
manifoldc | ||
SHARED | ||
manifoldc.cpp | ||
conv.cpp | ||
box.cpp | ||
cross.cpp | ||
rect.cpp | ||
) | ||
add_library(manifold::manifoldc ALIAS manifoldc) | ||
set_property(TARGET manifoldc PROPERTY VERSION "${MANIFOLD_VERSION}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Namespace alias so users can just do |
||
set_property(TARGET manifoldc PROPERTY SOVERSION ${MANIFOLD_VERSION_MAJOR}) | ||
|
||
if(MSVC) | ||
set_target_properties(manifoldc PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
|
@@ -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) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we have the global |
||
install(TARGETS manifoldc EXPORT manifoldTargets) | ||
install( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure we will not do download when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and I thought of moving this to |
||
FetchContent_Declare( | ||
nanobind | ||
GIT_REPOSITORY https://github.com/wjakob/nanobind.git | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
) | ||
|
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 " ") |
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() |
There was a problem hiding this comment.
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.