@@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 3.12)
22
33project (rcutils)
44
5+ option (RCUTILS_NO_THREAD_SUPPORT "Disable thread support." OFF )
6+ option (RCUTILS_NO_FILESYSTEM "Disable filesystem usage." OFF )
7+ option (RCUTILS_AVOID_DYNAMIC_ALLOCATION "Disable dynamic allocations." OFF )
8+ option (RCUTILS_NO_64_ATOMIC "Enable alternative support for 64 bits atomic operations in platforms with no native support." OFF )
9+ option (RCUTILS_MICROROS "Flag for building micro-ROS." ON )
10+
511# Default to C11
612if (NOT CMAKE_C_STANDARD )
713 set (CMAKE_C_STANDARD 11)
@@ -30,7 +36,7 @@ if(UNIX AND NOT APPLE)
3036 endif ()
3137endif ()
3238
33- if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
39+ if (NOT RCUTILS_MICROROS AND ( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) )
3440 # enables building a static library but later link it into a dynamic library
3541 add_compile_options (-fPIC )
3642endif ()
@@ -75,6 +81,7 @@ set(rcutils_sources
7581 src/time.c
7682 ${time_impl_c}
7783 src/uint8_array.c
84+ $<$<BOOL :${RCUTILS_NO_64_ATOMIC} >:src /atomic_64bits .c >
7885)
7986set_source_files_properties (
8087 ${rcutils_sources}
@@ -129,8 +136,14 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE "RCUTILS_BUILDING_DLL")
129136if (BUILD_TESTING AND NOT RCUTILS_DISABLE_FAULT_INJECTION)
130137 target_compile_definitions (${PROJECT_NAME } PUBLIC RCUTILS_ENABLE_FAULT_INJECTION )
131138endif ()
139+ configure_file (
140+ "${PROJECT_SOURCE_DIR } /include/rcutils/configuration_flags.h.in"
141+ "${PROJECT_BINARY_DIR } /include/rcutils/configuration_flags.h"
142+ )
132143
133- target_link_libraries (${PROJECT_NAME } ${CMAKE_DL_LIBS } )
144+ if (NOT RCUTILS_NO_FILESYSTEM)
145+ target_link_libraries (${PROJECT_NAME } ${CMAKE_DL_LIBS } )
146+ endif ()
134147
135148check_library_exists (atomic __atomic_load_8 "" HAVE_LIBATOMICS )
136149
@@ -282,7 +295,7 @@ if(BUILD_TESTING)
282295 )
283296 if (TARGET test_error_handling_helpers)
284297 target_include_directories (test_error_handling_helpers PUBLIC include )
285- target_link_libraries (test_error_handling_helpers osrf_testing_tools_cpp::memory_tools )
298+ target_link_libraries (test_error_handling_helpers ${ PROJECT_NAME } osrf_testing_tools_cpp::memory_tools )
286299 endif ()
287300
288301 rcutils_custom_add_gtest (test_split
@@ -587,7 +600,10 @@ endif()
587600
588601# Export old-style CMake variables
589602ament_export_include_directories ("include/${PROJECT_NAME } " )
590- ament_export_libraries (${PROJECT_NAME } ${CMAKE_DL_LIBS } )
603+
604+ if (NOT RCUTILS_NO_FILESYSTEM)
605+ ament_export_libraries (${PROJECT_NAME } ${CMAKE_DL_LIBS } )
606+ endif ()
591607
592608# Export modern CMake targets
593609ament_export_targets (${PROJECT_NAME } )
0 commit comments