Skip to content

Commit 20ae34b

Browse files
committed
Mess backup before I left
1 parent 58e7034 commit 20ae34b

File tree

24 files changed

+300
-118
lines changed

24 files changed

+300
-118
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# Build folders
2+
build/
3+
build_osx/
4+
cmake-build-debug/
5+
cmake-build-release/
6+
7+
# IDEs
8+
.idea/
9+
110
#######################################
211
## C++
312
#######################################

CMakeLists.txt

Lines changed: 68 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cmake_minimum_required(VERSION 3.16.)
22
project(diffCheck VERSION 1.3.0 LANGUAGES CXX C)
33
set(CMAKE_CXX_STANDARD 17)
4-
# set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
54

65
# Force usage of libc++ and proper visibility on macOS
76
# For some reason, without this, there will be a segfault in test
@@ -10,9 +9,6 @@ if(APPLE)
109
add_link_options(-stdlib=libc++)
1110
endif()
1211

13-
# # Set rpath for Python extension loading on macOS
14-
# set(CMAKE_MACOSX_RPATH ON)
15-
1612
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
1713

1814
include(external_tools)
@@ -53,17 +49,22 @@ set(SHARED_LIB_NAME diffCheck)
5349
file(GLOB_RECURSE SOURCES_LIB
5450
src/diffCheck.hh # diffCheck interface
5551
src/diffCheck/*.cc src/diffCheck/*.hh # diffCheck src
56-
src/diffCheck/*/*.cc src/diffCheck/*/*.hh # diffCheck submodules
5752
)
5853

59-
# print the sources founded
54+
# For some reason, on macOS, we need to compile the library as static
55+
# I wonder if it's a good idea to also compile the library as static on Windows
56+
# if (APPLE)
57+
# add_library(${SHARED_LIB_NAME} STATIC ${SOURCES_LIB})
58+
# else()
6059
add_library(${SHARED_LIB_NAME} STATIC ${SOURCES_LIB})
61-
62-
# if (WIN32)
63-
# set_target_properties(${SHARED_LIB_NAME} PROPERTIES
64-
# WINDOWS_EXPORT_ALL_SYMBOLS TRUE
65-
# )
6660
# endif()
61+
62+
if (WIN32)
63+
set_target_properties(${SHARED_LIB_NAME} PROPERTIES
64+
WINDOWS_EXPORT_ALL_SYMBOLS TRUE
65+
)
66+
endif()
67+
6768
set_target_properties(${SHARED_LIB_NAME} PROPERTIES
6869
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
6970
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
@@ -74,9 +75,10 @@ target_include_directories(${SHARED_LIB_NAME}
7475
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
7576
)
7677

77-
#set the MD_DynamicRelease flag for MSVC since we are compiling with /MD for py wrap
78-
# set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
79-
78+
# set the MD_DynamicRelease flag for MSVC since we are compiling with /MD for py wrap
79+
if (WIN32)
80+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
81+
endif()
8082

8183
#--------------------------------------------------------------------------
8284
# 3rd party
@@ -89,30 +91,32 @@ target_link_libraries(${SHARED_LIB_NAME} PUBLIC Eigen3::Eigen)
8991

9092
# Open3D (pre-built binaries) ---------------------------------------------
9193
# download_submodule_project(open3d)
92-
# set(Open3D_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/open3d/win/0_18/CMake)
93-
# find_package(Open3D 0.18.0 REQUIRED)
94-
95-
# # print the version debug or release of the package
96-
# message(STATUS "Open3D version: ${Open3D_VERSION}"
97-
# "Open3D include dir: ${Open3D_INCLUDE_DIRS}"
98-
# "Open3D library dir: ${Open3D_LIBRARIES}")
94+
if (WIN32)
95+
set(Open3D_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/open3d/win/0_18/CMake)
96+
elseif (APPLE)
97+
set(Open3D_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/open3d/mac/open3d-devel-darwin-arm64-0.18.0/lib/cmake/Open3D)
98+
endif()
99+
find_package(Open3D 0.18.0 REQUIRED)
99100

101+
# find_package(Open3D HINTS ${CMAKE_INSTALL_PREFIX}/lib/cmake)
100102

101-
find_package(Open3D HINTS ${CMAKE_INSTALL_PREFIX}/lib/cmake)
102103
# link the release version of the open3d library
103104
target_link_libraries(${SHARED_LIB_NAME} PUBLIC Open3D::Open3D)
104105

105106
# On Windows if BUILD_SHARED_LIBS is enabled, copy .dll files to the executable directory
106-
# if(WIN32)
107-
# get_target_property(open3d_type Open3D::Open3D TYPE)
108-
# if(open3d_type STREQUAL "SHARED_LIBRARY")
109-
# message(STATUS "Copying Open3D.dll to ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
110-
# add_custom_command(TARGET ${SHARED_LIB_NAME} POST_BUILD
111-
# COMMAND ${CMAKE_COMMAND} -E copy
112-
# $<TARGET_FILE:Open3D::Open3D>
113-
# $<TARGET_FILE_DIR:${SHARED_LIB_NAME}>)
114-
# endif()
115-
# endif()
107+
if(WIN32)
108+
get_target_property(open3d_type Open3D::Open3D TYPE)
109+
if(open3d_type STREQUAL "SHARED_LIBRARY")
110+
message(STATUS "Copying Open3D.dll to ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
111+
add_custom_command(TARGET ${SHARED_LIB_NAME} POST_BUILD
112+
COMMAND ${CMAKE_COMMAND} -E copy
113+
$<TARGET_FILE:Open3D::Open3D>
114+
$<TARGET_FILE_DIR:${SHARED_LIB_NAME}>)
115+
endif()
116+
endif()
117+
118+
119+
116120

117121
# Boost (header only) -----------------------------------------------------
118122
download_submodule_project(boost)
@@ -133,19 +137,19 @@ target_link_libraries(${SHARED_LIB_NAME} PUBLIC loguru::loguru)
133137
#--------------------------------------------------------------------------
134138
# executable for prototyping
135139
#--------------------------------------------------------------------------
136-
# set(APP_NAME_EXE diffCheckApp)
140+
set(APP_NAME_EXE diffCheckApp)
137141

138-
# add_executable(${APP_NAME_EXE} src/diffCheckApp.cc)
142+
add_executable(${APP_NAME_EXE} src/diffCheckApp.cc)
139143

140-
# set_target_properties(${APP_NAME_EXE} PROPERTIES
141-
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
142-
# )
144+
set_target_properties(${APP_NAME_EXE} PROPERTIES
145+
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
146+
)
143147

144-
# target_link_libraries(${APP_NAME_EXE} ${SHARED_LIB_NAME})
148+
target_link_libraries(${APP_NAME_EXE} ${SHARED_LIB_NAME})
145149

146-
# target_include_directories(${APP_NAME_EXE}
147-
# PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
148-
# )
150+
target_include_directories(${APP_NAME_EXE}
151+
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
152+
)
149153

150154
#--------------------------------------------------------------------------
151155
# pybind11
@@ -154,9 +158,10 @@ add_definitions(-D_GLIBCXX_DEBUG)
154158

155159
if (BUILD_PYTHON_MODULE)
156160
set(PYBINDMODULE_NAME diffcheck_bindings)
157-
# set(PYPI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/gh/diffCheck/diffCheck)
158-
# set(TARGET_DLL_PYPI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/gh/diffCheck/diffCheck/dlls)
159-
# set(SPHINX_DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/doc)
161+
set(PYPI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/gh/diffCheck/diffCheck)
162+
set(TARGET_DLL_PYPI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/gh/diffCheck/diffCheck/dlls)
163+
set(TARGET_SO_PYPI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/gh/diffCheck/diffCheck)
164+
set(SPHINX_DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/doc)
160165

161166
download_submodule_project(pybind11)
162167
add_subdirectory(deps/pybind11)
@@ -179,19 +184,25 @@ if (BUILD_PYTHON_MODULE)
179184
target_link_libraries(${PYBINDMODULE_NAME} PUBLIC ${SHARED_LIB_NAME})
180185

181186
# copy the pyd file to the pypi directory
182-
# add_custom_command(TARGET ${PYBINDMODULE_NAME} POST_BUILD
183-
# COMMAND ${CMAKE_COMMAND} -E copy
184-
# $<TARGET_FILE:${PYBINDMODULE_NAME}>
185-
# ${PYPI_DIR}
186-
# )
187-
# copy_dlls(${TARGET_DLL_PYPI_DIR} ${PYBINDMODULE_NAME})
188-
# # copy the pyd/dlls for the sphinx documentation
189-
# add_custom_command(TARGET ${PYBINDMODULE_NAME} POST_BUILD
190-
# COMMAND ${CMAKE_COMMAND} -E copy
191-
# $<TARGET_FILE:${PYBINDMODULE_NAME}>
192-
# ${SPHINX_DOC_DIR}
193-
# )
194-
# copy_dlls(${SPHINX_DOC_DIR} ${PYBINDMODULE_NAME})
187+
add_custom_command(TARGET ${PYBINDMODULE_NAME} POST_BUILD
188+
COMMAND ${CMAKE_COMMAND} -E copy
189+
$<TARGET_FILE:${PYBINDMODULE_NAME}>
190+
${PYPI_DIR}
191+
)
192+
# copy the pyd/dlls for the sphinx documentation
193+
add_custom_command(TARGET ${PYBINDMODULE_NAME} POST_BUILD
194+
COMMAND ${CMAKE_COMMAND} -E copy
195+
$<TARGET_FILE:${PYBINDMODULE_NAME}>
196+
${SPHINX_DOC_DIR}
197+
)
198+
199+
if (WIN32)
200+
copy_dlls(${TARGET_DLL_PYPI_DIR} ${PYBINDMODULE_NAME})
201+
copy_dlls(${SPHINX_DOC_DIR} ${PYBINDMODULE_NAME})
202+
elseif (APPLE)
203+
copy_so_files(${TARGET_SO_PYPI_DIR} ${PYBINDMODULE_NAME})
204+
copy_so_files(${SPHINX_DOC_DIR} ${PYBINDMODULE_NAME})
205+
endif()
195206
endif()
196207

197208
# install the diffCheck shared library to the system path
@@ -201,9 +212,6 @@ install(TARGETS ${SHARED_LIB_NAME}
201212
RUNTIME DESTINATION bin
202213
)
203214

204-
205-
206-
207215
#--------------------------------------------------------------------------
208216
# Tests
209217
#--------------------------------------------------------------------------

cmake/external_tools.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,14 @@ function (copy_dlls directory_to_copy_dlls post_build_target)
247247
${directory_to_copy_dlls}
248248
)
249249
endforeach()
250+
endfunction()
251+
252+
# ------------------------------------------------------------------------------
253+
function (copy_so_files directory_to_copy_so_files post_build_target)
254+
message (STATUS "Erasing old SO files and copy new ones to ${directory_to_copy_so_files}")
255+
file(GLOB files ${directory_to_copy_so_files}/*.so)
256+
foreach(file ${files})
257+
message(STATUS "Removing ${file}")
258+
file(REMOVE ${file})
259+
endforeach()
250260
endfunction()

cmake/tests.cmake

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ copy_dlls(${TEST_OUT_DIR_BINARY} ${CPP_UNIT_TESTS})
2929
# ------------------------------------------------------------------------------
3030
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
3131

32+
# find python executable
33+
message(STATUS "Python3_EXECUTABLE: ${Python3_EXECUTABLE}")
34+
35+
# find python include dir
36+
message(STATUS "Python3_INCLUDE_DIRS: ${Python3_INCLUDE_DIRS}")
37+
38+
# find python library
39+
message(STATUS "Python3_LIBRARIES: ${Python3_LIBRARIES}")
40+
41+
set(PYTHON_EXECUTABLE /opt/homebrew/Caskroom/miniconda/base/bin/python)
42+
3243
# copying pyd and dlls
3344
set(TARGET_PYBIND_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/integration_tests/pybinds_tests)
3445
add_custom_command(TARGET ${PYBINDMODULE_NAME} POST_BUILD
@@ -55,11 +66,11 @@ add_test(NAME PYBIND_UNIT_TEST
5566
# Run all tests
5667
# ------------------------------------------------------------------------------
5768
# FIXME: the post build has some problems if the tests are failing MSB3073
58-
if (RUN_TESTS)
59-
add_custom_command(
60-
TARGET ${CPP_UNIT_TESTS} POST_BUILD #TODO: <== this should be set to the latest test suite
61-
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
62-
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --verbose
63-
COMMENT "Running all tests"
64-
)
65-
endif()
69+
#if (RUN_TESTS)
70+
# add_custom_command(
71+
# TARGET ${CPP_UNIT_TESTS} POST_BUILD #TODO: <== this should be set to the latest test suite
72+
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
73+
# COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --verbose
74+
# COMMENT "Running all tests"
75+
# )
76+
#endif()

deps/eigen

Submodule eigen updated from 8b4efc8 to 1e65707

deps/open3d_win

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 7f83ddfcbbb512824f358c365a3c62f6cd246f87

deps/pybind11

Submodule pybind11 updated 230 files

dev_log.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Deploy on Mac dev log
2+
## Current status
3+
- The pybind part can be successfully compiled and run on mac, within Grasshopper
4+
- Some functions do not work; Grasshopper would crash without any information once the function is called (which is also very hard to debug). Based on the current experiment, these functions are problematic:
5+
- `dfb_segmentation.DFSegmentation.associate_clusters`
6+
7+
## Run
8+
To just run on Mac (using the pre-compiled stuff), please navigate to the folder `/portability_experiment`.
9+
If you want to compile, follow the instruction below:
10+
11+
1. Make sure that `/deps/open3d/mac/open3d-devel-darwin-arm64-0.18.0/lib/cmake/Open3D` exist.
12+
2. Run the cmake & build as usual (make sure that you're using python3.9!)
13+
```
14+
mkdir build_mac
15+
cd build_mac
16+
cmake .. -DRUN_TESTS=OFF
17+
make -j
18+
```
19+
3. After building, you should see this file `/src/gh/diffCheck/diffCheck/diffcheck_bindings.cpython-39-darwin.so`
20+
4. Go to `src/gh/diffCheck` and build the wheel, and you should see the `diffcheck-1.3.0-py3-none-any.whl` appear in a sub-folder `dist`.
21+
```
22+
cd ..
23+
cd src/gh/diffCheck
24+
python setup.py bdist_wheel
25+
```
26+
4. Install diffCheck to Grasshopper's python
27+
```
28+
/Users/petingo/.rhinocode/py39-rh8/python3.9 -m pip install dist/diffcheck-1.3.0-py3-none-any.whl --force-reinstall
29+
```
30+
5. You should be able to use diffCheck in Grasshopper's python now.
31+
32+
## Changes to mac build
33+
- Everything in `diffcheck_binding` is now a part of `diffCheck` Instead of doing
34+
```
35+
from diffcheck_binding import xxx
36+
```
37+
You need to change it to
38+
```
39+
from diffCheck import xxx
40+
```

doc/development_env.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
If you develop for DF, you need to set up your development environment. This guide will help you to do that. Wether you are developing for the `c++` or `python` part of the project, you will find the necessary information here.
55

66
## Prepare your environment
7-
7+
### Windows
88
Before to start, especially if you used diffCheck as an end-user before you will need to:
99

1010
1. Make sure to have `camke` installed on your machine. You can download it [here](https://cmake.org/download/).
@@ -50,6 +50,11 @@ Before to start, especially if you used diffCheck as an end-user before you will
5050
For your info the packages is installed in `C:\Users\andre\.rhinocode\py39-rh8\Lib\site-packages`.
5151
```
5252

53+
### Mac
54+
```
55+
/Users/petingo/.rhinocode/py39-rh8/python3.9 -m pip install -e "/Users/petingo/p/diffCheck/src/gh/diffCheck"
56+
```
57+
5358
That's it you are now a contributor to the diffCheck! We raccomand to not download anymore from yak package but rather use the source code in the repository. If you want the latest diffCheck, checkout and pull the main.
5459
5560
---

environment.yml

-738 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)