Skip to content

Commit a0bc7fd

Browse files
authored
Cmake fetch assimp (#300)
1 parent 7a5c28f commit a0bc7fd

File tree

11 files changed

+25
-1074
lines changed

11 files changed

+25
-1074
lines changed

.github/workflows/config.yml

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -74,49 +74,6 @@ jobs:
7474
cd build/tests
7575
ctest --output-on-failure
7676
77-
vcpkg-on-linux:
78-
79-
runs-on: ${{ matrix.os }}
80-
env:
81-
CC: gcc-${{ matrix.compiler_version }}
82-
CXX: g++-${{ matrix.compiler_version }}
83-
strategy:
84-
fail-fast: false
85-
matrix:
86-
os: [ubuntu-22.04]
87-
compiler_version: [11]
88-
89-
steps:
90-
- uses: actions/checkout@v4
91-
92-
- name: Install prerequisites
93-
run: |
94-
sudo apt-get update && sudo apt-get install -y \
95-
libxinerama-dev \
96-
libxcursor-dev \
97-
xorg-dev \
98-
libglu1-mesa-dev \
99-
pkg-config
100-
101-
- name: Restore artifacts, or run vcpkg, build (and cache artifacts as post step)
102-
uses: lukka/run-vcpkg@v10
103-
id: runvcpkg
104-
with:
105-
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
106-
vcpkgGitCommitId: '4cac260c4b7331538d31886f57739fea0bffa27e'
107-
vcpkgJsonGlob: 'vcpkg.json'
108-
appendedCacheKey: vcpkginstall
109-
110-
- name: Configure and build
111-
run: |
112-
cmake . -B build -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_MANIFEST_FEATURES="assimp" -DCMAKE_BUILD_TYPE="Release"
113-
cmake --build build
114-
115-
- name: Test
116-
run: |
117-
cd build/tests
118-
ctest --output-on-failure
119-
12077
12178
windows:
12279

@@ -188,5 +145,5 @@ jobs:
188145

189146
- name: Configure and build
190147
run: |
191-
cmake . -B build -DCMAKE_TOOLCHAIN_FILE=${{env.EMSDK}}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DTHREEPP_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE="Release"
148+
cmake . -B build -DCMAKE_TOOLCHAIN_FILE=${{env.EMSDK}}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DTHREEPP_BUILD_TESTS=OFF -DTHREEPP_FETCH_ASSIMP=OFF -DCMAKE_BUILD_TYPE="Release"
192149
cmake --build build

CMakeLists.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ option(THREEPP_BUILD_TESTS "Build test suite" ON)
1010
option(THREEPP_WITH_SVG "Build with SVGLoader" ON)
1111
option(THREEPP_WITH_AUDIO "Build with Audio" ON)
1212
option(THREEPP_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
13-
option(THREEPP_BUILD_EXAMPLE_PROJECTS "Build example projects" ON)
13+
1414

1515
# Force THREEPP_WITH_GLFW ON when targeting Emscripten
1616
cmake_dependent_option(THREEPP_WITH_GLFW "Build with GLFW frontend" ON "NOT DEFINED EMSCRIPTEN" ON)
1717
# Force THREEPP_USE_EXTERNAL_GLFW OFF if NOT THREEPP_WITH_GLFW
1818
cmake_dependent_option(THREEPP_USE_EXTERNAL_GLFW "Use externally supplied GLFW" OFF "THREEPP_WITH_GLFW" OFF)
1919

20+
cmake_dependent_option(THREEPP_BUILD_EXAMPLE_PROJECTS "Build example projects" ON "THREEPP_BUILD_EXAMPLES" OFF)
21+
cmake_dependent_option(THREEPP_FETCH_ASSIMP "Make assimp available for examples" ON "THREEPP_BUILD_EXAMPLES" OFF)
22+
2023
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
2124

2225

@@ -62,6 +65,21 @@ endif ()
6265
add_subdirectory(src)
6366

6467
if (THREEPP_BUILD_EXAMPLES)
68+
69+
if (THREEPP_FETCH_ASSIMP)
70+
message("Fetching assimp for examples..")
71+
72+
include(FetchContent)
73+
set(ASSIMP_BUILD_TESTS OFF)
74+
set(ASSIMP_INSTALL OFF)
75+
FetchContent_Declare(
76+
assimp
77+
GIT_REPOSITORY https://github.com/assimp/assimp.git
78+
GIT_TAG v6.0.2
79+
)
80+
FetchContent_MakeAvailable(assimp)
81+
endif ()
82+
6583
add_subdirectory(examples)
6684
endif ()
6785

README.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,40 +54,20 @@ cmake . -B build -DCMAKE_BUILD_TYPE="Release"
5454
cmake --build build
5555
```
5656

57-
However, some of the examples (and headers) require additional dependencies.
58-
To make use of all features and to enable/build all examples, the use of [vcpkg](https://vcpkg.io/en/index.html) is encouraged.
59-
60-
#### Using vcpkg for getting optional dependecies (using manifest mode)
61-
62-
Call CMake with `-DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake`
63-
64-
Add optional features by listing them with `-DVCPKG_MANIFEST_FEATURES=feature1;feature2`
65-
66-
See [vcpkg.json](vcpkg.json) for available features.
67-
68-
Note, however, that under MinGW you'll need to specify the vcpkg triplet:
69-
```shell
70-
-DVCPKG_TARGET_TRIPLET=x64-mingw-[static|dynamic] # choose either `static` or `dynamic`.
71-
-DVCPKG_HOST_TRIPLET=x64-mingw-[static|dynamic] # <-- needed only if MSVC cannot be found.
72-
```
73-
7457
##### Building examples with Emscripten
7558

7659
Pass to CMake:
7760
```shell
7861
-DCMAKE_TOOLCHAIN_FILE="[path to emscripten]\emsdk\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake"
7962
```
80-
When using vcpkg, however, do:
81-
```shell
82-
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="[path to emscripten]\emsdk\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake"
83-
```
63+
8464
This will generate .html versions of a subset of the examples to be loaded in a browser.
8565

8666

8767
##### Optional downstream dependencies
8868

8969
When consuming `threepp` in your own application,
90-
some headers will require additional dependencies in order to compile.
70+
some headers will require additional dependencies to compile.
9171

9272
| **Header** | **Dependency** | **Description** |
9373
|--------------|----------------|-----------------------------------------------|

examples/AddExample.cmake

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
function(add_example)
33

4-
set(flags LINK_IMGUI LINK_ASSIMP LINK_XML LINK_PHYSX WEB)
4+
set(flags LINK_IMGUI LINK_ASSIMP LINK_XML WEB)
55
set(oneValueArgs NAME)
66
set(multiValueArgs SOURCES WEB_EMBED)
77

@@ -11,16 +11,11 @@ function(add_example)
1111
return()
1212
endif ()
1313

14-
if (arg_LINK_ASSIMP AND NOT assimp_FOUND)
14+
if (arg_LINK_ASSIMP AND (TARGET(assimp::assimp)))
1515
message(AUTHOR_WARNING "assimp not found, skipping '${arg_NAME}' example..")
1616
return()
1717
endif ()
1818

19-
if (arg_LINK_PHYSX AND NOT unofficial-omniverse-physx-sdk_FOUND)
20-
message(AUTHOR_WARNING "physx not found, skipping '${arg_NAME}' example..")
21-
return()
22-
endif ()
23-
2419
if (NOT arg_SOURCES)
2520
add_executable("${arg_NAME}" "${arg_NAME}.cpp")
2621
else ()
@@ -33,14 +28,10 @@ function(add_example)
3328
target_link_libraries("${arg_NAME}" PRIVATE imgui::imgui)
3429
endif ()
3530

36-
if (arg_LINK_ASSIMP AND assimp_FOUND)
31+
if (arg_LINK_ASSIMP)
3732
target_link_libraries("${arg_NAME}" PRIVATE assimp::assimp)
3833
endif ()
3934

40-
if (arg_LINK_PHYSX AND unofficial-omniverse-physx-sdk_FOUND)
41-
target_link_libraries("${arg_NAME}" PRIVATE unofficial::omniverse-physx-sdk::sdk)
42-
endif ()
43-
4435
if (DEFINED EMSCRIPTEN)
4536

4637
set(LINK_FLAGS " --bind -sUSE_GLFW=3 -sGL_DEBUG=1 -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sFULL_ES3 -sASSERTIONS -sALLOW_MEMORY_GROWTH -sNO_DISABLE_EXCEPTION_CATCHING -sWASM=1")

examples/LibConfig.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

22
find_package(assimp CONFIG QUIET)
3-
find_package(unofficial-omniverse-physx-sdk CONFIG QUIET)
43

54
add_subdirectory(external)

examples/extras/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11

22
add_subdirectory(core)
33
add_subdirectory(curves)
4-
add_subdirectory(physics)

examples/extras/physics/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)