Skip to content

Commit aed1509

Browse files
Michel Schmidg3force
Michel Schmid
authored andcommitted
build ODE from source if the package is not found, even if flag is not set
1 parent 89860fa commit aed1509

File tree

3 files changed

+51
-41
lines changed

3 files changed

+51
-41
lines changed

.github/workflows/build.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: "Build"
3636
# for some reason qt5 is not correctly in the path and this will break whenever the location of it changes
3737
# 5.15.11 is for macos-12 and 5.15.12 is for macos-13
38-
run: PATH=/usr/local/Cellar/qt@5/5.15.11/lib/cmake/Qt5:/usr/local/Cellar/qt@5/5.15.12/lib/cmake/Qt5:$PATH && make BUILD_ODE=ON
38+
run: PATH=/usr/local/Cellar/qt@5/5.15.11/lib/cmake/Qt5:/usr/local/Cellar/qt@5/5.15.12/lib/cmake/Qt5:$PATH && make
3939

4040
build-windows:
4141
runs-on: windows-latest

CMakeLists.txt

+16-40
Original file line numberDiff line numberDiff line change
@@ -83,48 +83,24 @@ list(APPEND libs Qt5::Core Qt5::Widgets Qt5::OpenGL Qt5::Network)
8383

8484
# ODE
8585
if(BUILD_ODE)
86-
# build ODE, because some versions of it cause grSim to segfault somewhere
87-
# could be because in some packages the double precision is turned off
88-
include(ExternalProject)
89-
90-
ExternalProject_Add(ode_external
91-
GIT_REPOSITORY https://bitbucket.org/odedevs/ode.git
92-
GIT_TAG 0.16.4
93-
CMAKE_ARGS
94-
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
95-
-DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE}
96-
-DCMAKE_C_COMPILER:PATH=${CMAKE_C_COMPILER}
97-
-DCMAKE_CXX_COMPILER:PATH=${CMAKE_CXX_COMPILER}
98-
-DCMAKE_MAKE_PROGRAM:PATH=${CMAKE_MAKE_PROGRAM}
99-
# necessary, because it does not build the static libs if this is ON
100-
-DBUILD_SHARED_LIBS=OFF
101-
# if this is OFF grSim just dies instantly and INSTALL.md says it should be ON
102-
-DODE_DOUBLE_PRECISION=ON
103-
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
104-
STEP_TARGETS install
105-
)
106-
107-
set(ODE_LIB_SUBPATH "${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}ode${CMAKE_STATIC_LIBRARY_SUFFIX}")
108-
109-
# the byproducts are available after the install step
110-
ExternalProject_Add_Step(ode_external out
111-
DEPENDEES install
112-
BYPRODUCTS
113-
"<INSTALL_DIR>/${ODE_LIB_SUBPATH}"
114-
)
115-
116-
ExternalProject_Get_Property(ode_external install_dir)
117-
set(ODE_LIBRARY "${install_dir}/${ODE_LIB_SUBPATH}")
118-
list(APPEND libs ${ODE_LIBRARY})
119-
target_include_directories(${app} PRIVATE "${install_dir}/include")
120-
86+
include(BuildODE)
12187
add_dependencies(${app} ode_external)
122-
elseif(WIN32)
123-
find_package(ODE CONFIG REQUIRED)
124-
list(APPEND libs ODE::ODE)
12588
else()
126-
find_package(ODE REQUIRED)
127-
list(APPEND libs ode::ode)
89+
if(WIN32)
90+
find_package(ODE CONFIG)
91+
set(ODE_LIB_NAME ODE::ODE)
92+
else()
93+
find_package(ODE)
94+
set(ODE_LIB_NAME ode::ode)
95+
endif()
96+
97+
if(ODE_FOUND)
98+
list(APPEND libs ${ODE_LIB_NAME})
99+
else()
100+
# if ODE could not be found just build it
101+
include(BuildODE)
102+
add_dependencies(${app} ode_external)
103+
endif()
128104
endif()
129105

130106
# VarTypes

cmake/modules/BuildODE.cmake

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# build ODE, because some versions of it cause grSim to segfault somewhere
2+
# could be because in some packages the double precision is turned off
3+
include(ExternalProject)
4+
5+
ExternalProject_Add(ode_external
6+
GIT_REPOSITORY https://bitbucket.org/odedevs/ode.git
7+
GIT_TAG 0.16.4
8+
CMAKE_ARGS
9+
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
10+
-DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE}
11+
-DCMAKE_C_COMPILER:PATH=${CMAKE_C_COMPILER}
12+
-DCMAKE_CXX_COMPILER:PATH=${CMAKE_CXX_COMPILER}
13+
-DCMAKE_MAKE_PROGRAM:PATH=${CMAKE_MAKE_PROGRAM}
14+
# necessary, because it does not build the static libs if this is ON
15+
-DBUILD_SHARED_LIBS=OFF
16+
# if this is OFF grSim just dies instantly and INSTALL.md says it should be ON
17+
-DODE_DOUBLE_PRECISION=ON
18+
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
19+
STEP_TARGETS install
20+
)
21+
22+
set(ODE_LIB_SUBPATH "${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}ode${CMAKE_STATIC_LIBRARY_SUFFIX}")
23+
24+
# the byproducts are available after the install step
25+
ExternalProject_Add_Step(ode_external out
26+
DEPENDEES install
27+
BYPRODUCTS
28+
"<INSTALL_DIR>/${ODE_LIB_SUBPATH}"
29+
)
30+
31+
ExternalProject_Get_Property(ode_external install_dir)
32+
set(ODE_LIBRARY "${install_dir}/${ODE_LIB_SUBPATH}")
33+
list(APPEND libs ${ODE_LIBRARY})
34+
target_include_directories(${app} PRIVATE "${install_dir}/include")

0 commit comments

Comments
 (0)