Skip to content

Commit 21ccfaf

Browse files
committed
WIP: each module now has its own config.h
1 parent 1c38726 commit 21ccfaf

38 files changed

+457
-376
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@ else()
518518
set(EIGEN_MAX_STATIC_ALIGN_BYTES 16)
519519
endif()
520520

521-
include(${MRPT_SOURCE_DIR}/cmakemodules/script_create_config_h.cmake REQUIRED) # Build config.h
522521
include(${MRPT_SOURCE_DIR}/cmakemodules/script_create_version_h.cmake REQUIRED) # Build version.h
523522

524523
add_custom_target(all_mrpt_libs ALL) # all_mrpt_libs: target to build all mrpt-* modules

cmakemodules/DeclareMRPTLib.cmake

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ function(mrpt_lib_target_requires_cpp17 _TARGET)
1818

1919
# Modern, clean way to do this:
2020
target_compile_features(${_TARGET} ${INTERF_TYPE} cxx_std_17)
21-
2221
endfunction()
2322

2423
# Minimize the time and memory required to build and load debug info:
@@ -450,6 +449,21 @@ macro(internal_define_mrpt_lib name headers_only )
450449
install(TARGETS ${name} EXPORT mrpt-${name}-targets)
451450
endif ()
452451

452+
# Create module/config.h file
453+
# ------------------------------------
454+
if (EXISTS ${MRPT_SOURCE_DIR}/libs/${name}/config.h.in)
455+
set(MODULES_BASE_CONFIG_INCLUDES_DIR ${CMAKE_BINARY_DIR}/include/mrpt-configuration/)
456+
set(MODULE_CONFIG_FILE_INCLUDE_DIR ${MODULES_BASE_CONFIG_INCLUDES_DIR}/mrpt/${name})
457+
file(MAKE_DIRECTORY ${MODULE_CONFIG_FILE_INCLUDE_DIR})
458+
459+
configure_file(${MRPT_SOURCE_DIR}/libs/${name}/config.h.in ${MODULE_CONFIG_FILE_INCLUDE_DIR}/config.h)
460+
461+
target_include_directories(${name} ${iftype}
462+
$<BUILD_INTERFACE:${MODULES_BASE_CONFIG_INCLUDES_DIR}>
463+
)
464+
install()
465+
endif()
466+
453467
# Create module CMake config file:
454468
# For local usage from the BUILD directory (without "install"):
455469
# 1/3: autogenerated target file:

cmakemodules/script_create_config_h.cmake

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

libs/containers/config.h.in

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* +---------------------------------------------------------------------------+
2+
| Mobile Robot Programming Toolkit (MRPT) |
3+
| https://www.mrpt.org/ |
4+
| |
5+
| Copyright (c) 2005-2024, Individual contributors, see AUTHORS file |
6+
| See: https://www.mrpt.org/Authors - All rights reserved. |
7+
| Released under BSD License. See details in https://www.mrpt.org/License |
8+
+---------------------------------------------------------------------------+
9+
*/
10+
11+
#pragma once
12+
13+
// clang-format off
14+
15+
/** Do we have libfyaml? */
16+
#define MRPT_HAS_FYAML ${CMAKE_MRPT_HAS_LIBFYAML}
17+
#define MRPT_HAS_FYAML_SYSTEM ${CMAKE_MRPT_HAS_LIBFYAML_SYSTEM}
18+
19+
// clang-format on

libs/containers/src/yaml.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "containers-precomp.h" // Precompiled headers
1111
//
12-
#include <mrpt/config.h>
12+
#include <mrpt/containers/config.h>
1313
#include <mrpt/containers/yaml.h>
1414
#include <mrpt/core/exceptions.h>
1515
#include <mrpt/core/get_env.h>

libs/core/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ set(MRPT_HAS_STACKED_EXCEPTIONS ON CACHE BOOL "Enable MRPT_TRY_START/END blocks
1212
# ASSERT_ blocks
1313
set(MRPT_HAS_ASSERT ON CACHE BOOL "Enable ASSERT_ statements (disable it for speed up).")
1414

15-
message("TODO******** PER PKG CONFIG.H with macros")
16-
1715
#---------------------------------------------
1816
# Macro declared in "DeclareMRPTLib.cmake":
1917
#---------------------------------------------

libs/core/config.h.in

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
/* +---------------------------------------------------------------------------+
2+
| Mobile Robot Programming Toolkit (MRPT) |
3+
| https://www.mrpt.org/ |
4+
| |
5+
| Copyright (c) 2005-2024, Individual contributors, see AUTHORS file |
6+
| See: https://www.mrpt.org/Authors - All rights reserved. |
7+
| Released under BSD License. See details in https://www.mrpt.org/License |
8+
+---------------------------------------------------------------------------+
9+
*/
10+
11+
#pragma once
12+
13+
// clang-format off
14+
15+
/** MRPT_BUILT_AS_DLL is defined only if MRPT has been built
16+
* as a shared library (.dll/.so) vs. a static library (.lib/.a).
17+
* Additionally, MRPT_EXPORTS will be defined only when compiling
18+
* the DLLs, not when the user imports them.
19+
*/
20+
${CMAKE_MRPT_BUILD_SHARED_LIB}
21+
22+
#define MRPT_HAS_TBB ${CMAKE_MRPT_HAS_TBB}
23+
24+
/** These two values are detected in Eigen when building MRPT, so we have
25+
the same settings given the user-provided flags */
26+
#define MRPT_MAX_ALIGN_BYTES ${EIGEN_MAX_ALIGN_BYTES}
27+
#define MRPT_MAX_STATIC_ALIGN_BYTES ${EIGEN_MAX_STATIC_ALIGN_BYTES}
28+
29+
/* Automatic definition of OS-macros */
30+
#if defined(_WIN32) || defined(_WIN32_) || defined(WIN32) || defined(_WIN64)
31+
#define MRPT_OS_WINDOWS
32+
#elif defined(unix) || defined(__unix__) || defined(__unix)
33+
#define MRPT_OS_LINUX
34+
#elif defined(__APPLE__)
35+
#define MRPT_OS_APPLE
36+
#else
37+
#error Unsupported platform (Found neither _WIN32_, __unix__ or __APPLE__)
38+
#endif
39+
40+
/** The architecture is 32 or 64 bit wordsize: */
41+
#define MRPT_WORD_SIZE ${CMAKE_MRPT_WORD_SIZE}
42+
43+
/** True if we are in amd64 or i386 architectures */
44+
#define MRPT_ARCH_INTEL_COMPATIBLE ${MRPT_ARCH_INTEL_COMPATIBLE}
45+
46+
/** Use optimized functions with the SSE2 machine instructions set */
47+
#if defined WIN32 && (!defined WIN64 || defined EM64T) && \
48+
(_MSC_VER >= 1400) || (defined __SSE2__ && defined __GNUC__ && __GNUC__ >= 4)
49+
#define MRPT_HAS_SSE2 ${CMAKE_MRPT_HAS_SSE2} // This value can be set to 0 from CMake with ENABLE_SSE2
50+
#else
51+
#define MRPT_HAS_SSE2 0
52+
#endif
53+
54+
/** Use optimized functions with the SSE3 machine instructions set */
55+
#if defined WIN32 && (!defined WIN64 || defined EM64T) && \
56+
(_MSC_VER >= 1500) || (defined __SSE3__ && defined __GNUC__ && __GNUC__ >= 4)
57+
#define MRPT_HAS_SSE3 ${CMAKE_MRPT_HAS_SSE3} // This value can be set to 0 from CMake with ENABLE_SSE3
58+
#else
59+
#define MRPT_HAS_SSE3 0
60+
#endif
61+
62+
// This value can be set to 0 from CMake with ENABLE_XXX
63+
#define MRPT_HAS_SSE4_1 ${CMAKE_MRPT_HAS_SSE4_1}
64+
#define MRPT_HAS_SSE4_2 ${CMAKE_MRPT_HAS_SSE4_2}
65+
#define MRPT_HAS_SSE4_A ${CMAKE_MRPT_HAS_SSE4_A}
66+
#define MRPT_HAS_AVX ${CMAKE_MRPT_HAS_AVX}
67+
#define MRPT_HAS_AVX2 ${CMAKE_MRPT_HAS_AVX2}
68+
#define MRPT_HAS_NEON ${CMAKE_MRPT_HAS_NEON}
69+
70+
/** Are we in a big-endian system? (Intel, amd, etc.. are little-endian) */
71+
#define MRPT_IS_BIG_ENDIAN ${CMAKE_MRPT_IS_BIG_ENDIAN}
72+
73+
/** Are we in an Emscripten build? */
74+
#define MRPT_IN_EMSCRIPTEN ${CMAKE_MRPT_IN_EMSCRIPTEN}
75+
76+
/** Standard headers */
77+
#ifndef HAVE_INTTYPES_H
78+
#cmakedefine HAVE_INTTYPES_H 1
79+
#endif
80+
81+
#ifndef HAVE_STDINT_H
82+
#cmakedefine HAVE_STDINT_H 1
83+
#endif
84+
85+
#ifndef HAVE_WINSOCK2_H
86+
#cmakedefine HAVE_WINSOCK2_H 1
87+
#endif
88+
89+
#ifndef HAVE_ALLOCA_H
90+
#cmakedefine HAVE_ALLOCA_H 1
91+
#endif
92+
93+
#ifndef HAVE_LINUX_SERIAL_H
94+
#cmakedefine HAVE_LINUX_SERIAL_H 1
95+
#endif
96+
97+
#ifndef HAVE_LINUX_INPUT_H
98+
#cmakedefine HAVE_LINUX_INPUT_H 1
99+
#endif
100+
101+
#ifndef HAVE_SYS_TIME_H
102+
#cmakedefine HAVE_SYS_TIME_H 1
103+
#endif
104+
105+
#ifndef HAVE_PTHREAD_H
106+
#cmakedefine HAVE_PTHREAD_H 1
107+
#endif
108+
109+
#ifndef HAVE_UNISTD_H
110+
#cmakedefine HAVE_UNISTD_H 1
111+
#endif
112+
113+
// Has <malloc.h>?
114+
#ifndef HAVE_MALLOC_H
115+
#cmakedefine HAVE_MALLOC_H 1
116+
#endif
117+
118+
// Has <malloc/malloc.h>?
119+
#ifndef HAVE_MALLOC_MALLOC_H
120+
#cmakedefine HAVE_MALLOC_MALLOC_H 1
121+
#endif
122+
123+
#ifndef HAVE_FREEGLUT_EXT_H
124+
#cmakedefine HAVE_FREEGLUT_EXT_H 1
125+
#endif
126+
127+
/** Standard functions */
128+
#ifndef HAVE_TIMEGM
129+
#cmakedefine HAVE_TIMEGM
130+
#endif
131+
132+
#ifndef HAVE_MKGMTIME
133+
#cmakedefine HAVE_MKGMTIME
134+
#endif
135+
136+
#ifndef HAVE_ALLOCA
137+
#cmakedefine HAVE_ALLOCA
138+
#endif
139+
140+
#ifndef HAVE_GETTID
141+
#cmakedefine HAVE_GETTID
142+
#endif
143+
144+
#ifndef HAVE_SINCOS
145+
#cmakedefine HAVE_SINCOS
146+
#endif
147+
148+
#ifndef HAVE_LRINT
149+
#cmakedefine HAVE_LRINT
150+
#endif
151+
152+
#ifndef HAVE_STRTOK_R
153+
#cmakedefine HAVE_STRTOK_R
154+
#endif
155+
156+
#ifndef HAVE_LOCALTIME_R
157+
#cmakedefine HAVE_LOCALTIME_R
158+
#endif
159+
160+
#ifndef HAVE_ALIGNED_MALLOC
161+
#cmakedefine HAVE_ALIGNED_MALLOC
162+
#endif
163+
164+
/* Standard types */
165+
#ifndef HAVE_LONG_DOUBLE
166+
#cmakedefine HAVE_LONG_DOUBLE
167+
#endif
168+
169+
/* BFD library for debug symbols */
170+
#define MRPT_HAS_BFD ${CMAKE_MRPT_HAS_BFD}
171+
#cmakedefine HAVE_DECL_BFD_SECTION_FLAGS 1
172+
#cmakedefine HAVE_DECL_BFD_GET_SECTION_FLAGS 1
173+
#cmakedefine HAVE_DECL_BFD_GET_SECTION_VMA 1
174+
#cmakedefine HAVE_DECL_BFD_SECTION_VMA 1
175+
#cmakedefine HAVE_1_ARG_BFD_SECTION_SIZE 1
176+
177+
178+
/* Defined only if MRPT is being build/was built with precompiled
179+
headers enabled */
180+
#cmakedefine MRPT_ENABLE_PRECOMPILED_HDRS 1
181+
182+
// -------------------------------
183+
// Some checks:
184+
// -------------------------------
185+
#if !defined(MRPT_OS_WINDOWS) && !defined(MRPT_OS_LINUX) && !defined(MRPT_OS_APPLE)
186+
#error Neither OS detected from MRPT_OS_LINUX, MRPT_OS_APPLE or MRPT_OS_WINDOWS!
187+
#endif
188+
189+
// clang-format on

libs/core/include/mrpt/core/SSE_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#pragma once
1111

12-
#include <mrpt/config.h>
12+
#include <mrpt/core/config.h>
1313

1414
// SSE2 types:
1515
#if MRPT_ARCH_INTEL_COMPATIBLE

libs/core/include/mrpt/core/alignment_req.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#pragma once
1111

1212
// This is to match Eigen expectations on alignment of dynamic objects:
13-
#include <mrpt/config.h>
13+
#include <mrpt/core/config.h>
1414

1515
// #define MRPT_MAX_ALIGN_BYTES XXX
1616
// #define MRPT_MAX_STATIC_ALIGN_BYTES XXX

libs/core/include/mrpt/core/initializer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* cross-platform implementation.
1616
*/
1717
#if defined(_MSC_VER)
18-
#include <mrpt/config.h>
18+
#include <mrpt/core/config.h>
1919
#if defined(MRPT_BUILT_AS_DLL)
2020
#define WIN32_LEAN_AND_MEAN
2121
#include <windows.h>

0 commit comments

Comments
 (0)