Skip to content

Commit 56f97d4

Browse files
author
Murilo M. Marinho
committed
[CMakeLists.txt] Updating to no longer using an ancient way of importing Eigen3.
1 parent 9519501 commit 56f97d4

File tree

3 files changed

+27
-40
lines changed

3 files changed

+27
-40
lines changed

CMakeLists.txt

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# Updated 2025.05 to 3.10 since compatibility with CMake < 3.10 will be removed from a future version of CMake.
22
cmake_minimum_required(VERSION 3.10)
3+
4+
# Added in case users want to build this library as STATIC
35
# https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html
46
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
57

68
if(WIN32)
79
set(CMAKE_TOOLCHAIN_FILE C:/vcpkg/scripts/buildsystems/vcpkg.cmake)
10+
# A must so that we don't need to manually export each public part of the library
811
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
912
endif()
1013

1114
project(dqrobotics)
12-
set (CMAKE_CXX_STANDARD 11)
15+
16+
find_package(Eigen3 REQUIRED)
1317

1418
# As of 2025.05, Not using GLOB_RECURSE as it's explicitly discouraged.
1519
# https://stackoverflow.com/questions/3201154/automatically-add-all-files-in-a-folder-to-a-target-using-cmake
@@ -50,57 +54,49 @@ add_library(dqrobotics
5054
src/robots/FrankaEmikaPandaRobot.cpp
5155
)
5256

53-
target_include_directories(
57+
set_property(TARGET dqrobotics PROPERTY CXX_STANDARD 17)
58+
59+
target_include_directories(dqrobotics PUBLIC
5460
include
5561
)
5662

57-
if(UNIX AND NOT APPLE)
58-
find_package(Eigen3 REQUIRED)
59-
include_directories(${EIGEN3_INCLUDE_DIR})
60-
add_compile_options(-Werror=return-type -Wall -Wextra -Wmissing-declarations -Wredundant-decls -Woverloaded-virtual)
61-
endif()
62-
63-
if(APPLE)
64-
include_directories(
65-
/usr/local/include/
66-
/usr/local/include/eigen3
67-
# Most recent versions of brew install here
68-
/opt/homebrew/include
69-
/opt/homebrew/include/eigen3)
70-
add_compile_options(-Werror=return-type -Wall -Wextra -Wmissing-declarations -Wredundant-decls -Woverloaded-virtual)
63+
if(UNIX)
64+
# WIN32 does not accept these flags
65+
add_compile_options(-Werror=return-type -Wall -Wextra -Wmissing-declarations -Wredundant-decls -Woverloaded-virtual -fPIC)
7166
endif()
7267

7368
if(WIN32)
74-
add_definitions(-D_USE_MATH_DEFINES)
75-
find_package(Eigen3 CONFIG REQUIRED)
76-
include_directories(${EIGEN3_INCLUDE_DIR})
69+
# https://learn.microsoft.com/en-us/cpp/c-runtime-library/math-constants?view=msvc-170
70+
target_compile_definitions(dqrobotics PUBLIC
71+
_USE_MATH_DEFINES
72+
)
7773
endif()
7874

75+
target_link_libraries(dqrobotics PUBLIC
76+
Eigen3::Eigen
77+
)
78+
7979
set_target_properties(dqrobotics
8080
PROPERTIES PUBLIC_HEADER
8181
include/dqrobotics/DQ.h
8282
)
8383

8484
install(TARGETS dqrobotics
85-
# https://stackoverflow.com/questions/21592361/cmake-install-is-not-installing-libraries-on-windows
85+
# https://stackoverflow.com/questions/21592361/cmake-install-is-not-installing-libraries-on-windows
8686
RUNTIME DESTINATION "bin"
8787
LIBRARY DESTINATION "lib"
8888
ARCHIVE DESTINATION "lib"
8989
PUBLIC_HEADER DESTINATION "include/dqrobotics"
90-
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
91-
92-
################################################################
93-
# INSTALL HEADERS IN SUBFOLDERS
94-
################################################################
90+
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
91+
)
9592

9693
install(DIRECTORY
9794
include/
98-
DESTINATION "include")
99-
100-
################################################################
101-
# INSTALL SOURCE FILES (So that the debugger can find them)
102-
################################################################
95+
DESTINATION "include"
96+
)
10397

98+
# Install source files so that the debugger can find them
10499
install(DIRECTORY
105100
src/
106-
DESTINATION "src/dqrobotics")
101+
DESTINATION "src/dqrobotics"
102+
)

include/dqrobotics/DQ.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ This file is part of DQ Robotics.
4242
*/
4343
#pragma once
4444

45-
#ifdef _WIN32
4645
#include <Eigen/Dense>
47-
#else
48-
#include <eigen3/Eigen/Dense>
49-
#endif
5046

5147
#include <iostream>
5248
using namespace Eigen;

include/dqrobotics/utils/DQ_LinearAlgebra.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ This file is part of DQ Robotics.
2121
- Murilo M. Marinho ([email protected])
2222
*/
2323

24-
#ifdef _WIN32
2524
#include <Eigen/Dense>
26-
#else
27-
#include <eigen3/Eigen/Dense>
28-
#endif
29-
3025
#include <tuple>
3126

3227
using namespace Eigen;

0 commit comments

Comments
 (0)