Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 7ea57cd

Browse files
committed
CMake: make C++ usage optional
1 parent cc3412a commit 7ea57cd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2017, Intel Corporation
2+
# Copyright 2017-2020, Intel Corporation
33
#
44
# Redistribution and use in source and binary forms, with or without
55
# modification, are permitted provided that the following conditions
@@ -30,7 +30,7 @@
3030
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131

3232
cmake_minimum_required(VERSION 3.3)
33-
project(syscall_intercept C CXX ASM)
33+
project(syscall_intercept C ASM)
3434

3535
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
3636
# Setting CMAKE_DISABLE_IN_SOURCE_BUILD to ON should
@@ -63,6 +63,7 @@ set(SYSCALL_INTERCEPT_VERSION
6363
include(cmake/find_capstone.cmake)
6464
include(GNUInstallDirs)
6565
include(cmake/toolchain_features.cmake)
66+
include(CheckLanguage)
6667

6768
# main source files - intentionally excluding src/cmdline_filter.c
6869
set(SOURCES_C
@@ -147,15 +148,18 @@ set_target_properties(syscall_intercept_shared
147148
PROPERTIES VERSION ${SYSCALL_INTERCEPT_VERSION}
148149
SOVERSION ${SYSCALL_INTERCEPT_VERSION_MAJOR})
149150

150-
add_executable(cpp_test src/cpp_compile_test.cc src/cpp_compile_mock.c)
151-
152151
set_target_properties(syscall_intercept_shared syscall_intercept_static
153152
PROPERTIES
154153
LINKER_LANGUAGE C
155154
PUBLIC_HEADER "include/libsyscall_intercept_hook_point.h"
156155
OUTPUT_NAME syscall_intercept)
157156

158-
add_dependencies(syscall_intercept_base_c cpp_test)
157+
check_language(CXX)
158+
if(CMAKE_CXX_COMPILER)
159+
enable_language(CXX)
160+
add_executable(cpp_test src/cpp_compile_test.cc src/cpp_compile_mock.c)
161+
add_dependencies(syscall_intercept_base_c cpp_test)
162+
endif()
159163

160164
if(PERFORM_STYLE_CHECKS)
161165
include(FindPerl)

0 commit comments

Comments
 (0)