mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -06:00
Tests/FindOpenMP: Verify linking to OpenMP libraries
Previously we only verified the `_OPENMP` preprocessor symbol.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(TestFindOpenMP NONE)
|
||||
include(CTest)
|
||||
|
||||
@@ -54,7 +54,7 @@ foreach(c C CXX Fortran)
|
||||
add_executable(test_var_${c} ${OpenMPTEST_SOURCE_FILE})
|
||||
separate_arguments(_OpenMP_${c}_OPTIONS NATIVE_COMMAND "${OpenMP_${c}_FLAGS}")
|
||||
target_compile_options(test_var_${c} PRIVATE "${_OpenMP_${c}_OPTIONS}")
|
||||
target_link_libraries(test_var_${c} PRIVATE "${OpenMP_${c}_FLAGS}")
|
||||
target_link_libraries(test_var_${c} PRIVATE ${OpenMP_${c}_LIBRARIES})
|
||||
target_include_directories(test_var_${c} PRIVATE ${OpenMP_${c}_INCLUDE_DIRS})
|
||||
set_property(TARGET test_var_${c} PROPERTY LINKER_LANGUAGE ${c})
|
||||
add_test(NAME test_var_${c} COMMAND test_var_${c})
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
#include <omp.h>
|
||||
int main(void)
|
||||
{
|
||||
#ifndef _OPENMP
|
||||
breaks_on_purpose
|
||||
#ifdef _OPENMP
|
||||
omp_get_num_threads();
|
||||
#else
|
||||
# error "_OPENMP not defined!"
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user