Skip to content

Commit bd2f0a3

Browse files
committed
CMake: don't depend on C++ compiler for main build
Only the tests actually require a C++ compiler, however CXX is globally enabled for the project, which prevents building on targets that do not have a C++ compiler available. Only enable C++ support selectively when building the tests is enabled too. Signed-off-by: Florian Larysch <fl@n621.de>
1 parent c2c569f commit bd2f0a3

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
cmake_minimum_required(VERSION 3.10)
2626

27-
project(tinycbor LANGUAGES C CXX VERSION 7.0)
27+
project(tinycbor LANGUAGES C VERSION 7.0)
2828

2929
# Set path to additional cmake scripts
3030
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
@@ -56,7 +56,7 @@ add_library(tinycbor
5656
)
5757
if(WITH_FREESTANDING)
5858
target_compile_options(tinycbor PUBLIC
59-
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-ffreestanding>
59+
$<$<NOT:$<C_COMPILER_ID:MSVC>>:-ffreestanding>
6060
)
6161
else()
6262
target_sources(tinycbor PRIVATE
@@ -106,8 +106,8 @@ endif()
106106

107107
# Enable warnings
108108
target_compile_options(tinycbor PRIVATE
109-
$<$<CXX_COMPILER_ID:MSVC>:-W3>
110-
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
109+
$<$<C_COMPILER_ID:MSVC>:-W3>
110+
$<$<NOT:$<C_COMPILER_ID:MSVC>>:
111111
-Wall -Wextra
112112
-Werror=format-security
113113
-Werror=incompatible-pointer-types
@@ -181,6 +181,7 @@ if(BUILD_EXAMPLES)
181181
add_subdirectory(examples)
182182
endif()
183183
if(BUILD_TESTING)
184+
enable_language(CXX)
184185
enable_testing()
185186
add_subdirectory(tests)
186187
endif()

0 commit comments

Comments
 (0)