From ce9d83be806941d48dc37034c0c6522a4bf09bb6 Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Thu, 28 May 2020 10:53:18 +0200 Subject: cmake/CFeatureCheck.cmake: fix feature tests failing when Opus is a submodule CMAKE_SOURCE_DIR corresponds to the top project's source directory. CMAKE_BINARY_DIR corresponds to the top project's binary directory. The usage of these variables doesn't cause any problems when Opus is built as a standalone project. This is not the case when Opus is added as submodule: the variables are set by the project that calls "add_subdirectory()". The fix consists in using PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR, which always refer to the current project. Signed-off-by: Mark Harris --- cmake/CFeatureCheck.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmake') diff --git a/cmake/CFeatureCheck.cmake b/cmake/CFeatureCheck.cmake index 4059f434..08828f58 100644 --- a/cmake/CFeatureCheck.cmake +++ b/cmake/CFeatureCheck.cmake @@ -27,7 +27,7 @@ function(c_feature_check FILE) if (NOT DEFINED COMPILE_${FEATURE}) message(STATUS "Performing Test ${FEATURE}") - try_compile(COMPILE_${FEATURE} ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/${FILE}.c) + try_compile(COMPILE_${FEATURE} ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/${FILE}.c) endif() if(COMPILE_${FEATURE}) @@ -36,4 +36,4 @@ function(c_feature_check FILE) else() message(STATUS "Performing Test ${FEATURE} -- failed to compile") endif() -endfunction() \ No newline at end of file +endfunction() -- cgit v1.2.3