[cmake] only require a CXX compiler when tests are build

Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
This commit is contained in:
Thomas Devoogdt
2025-05-06 12:20:26 -07:00
committed by Yann Collet
parent 2d224dc745
commit 769723aee2
2 changed files with 30 additions and 24 deletions
+13 -7
View File
@@ -37,7 +37,6 @@ project(zstd
VERSION "${ZSTD_FULL_VERSION}"
LANGUAGES C # Main library is in C
ASM # And ASM
CXX # Testing contributed code also utilizes CXX
)
message(STATUS "ZSTD VERSION: ${zstd_VERSION}")
@@ -54,12 +53,6 @@ endif()
include(GNUInstallDirs)
#-----------------------------------------------------------------------------
# Add extra compilation flags
#-----------------------------------------------------------------------------
include(AddZstdCompilationFlags)
ADD_ZSTD_COMPILATION_FLAGS()
# Always hide XXHash symbols
add_definitions(-DXXH_NAMESPACE=ZSTD_)
@@ -123,6 +116,19 @@ if (MSVC)
option(ZSTD_USE_STATIC_RUNTIME "LINK TO STATIC RUN-TIME LIBRARIES" OFF)
endif ()
# Enable C++ support for testing.
set(ZSTD_ENABLE_CXX ${ZSTD_BUILD_TESTS})
if(ZSTD_ENABLE_CXX)
enable_language(CXX)
endif()
#-----------------------------------------------------------------------------
# Add extra compilation flags
#-----------------------------------------------------------------------------
include(AddZstdCompilationFlags)
ADD_ZSTD_COMPILATION_FLAGS(ON ZSTD_ENABLE_CXX ON) # C CXX LD
#-----------------------------------------------------------------------------
# External dependencies
#-----------------------------------------------------------------------------