From 9b267eee4fd6d5f09b0167c69cabf49da5c8a540 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Mon, 29 Jul 2019 18:31:43 +0200 Subject: [PATCH 1/2] Properly detect openmp --- CMakeLists.txt | 6 ++++-- sz/CMakeLists.txt | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 30a6bd57..90d365a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,10 @@ endif() project (sz) enable_testing() -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=c99 -fopenmp") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11 -fopenmp") +find_package (OpenMP REQUIRED) + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=c99") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11") set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/sz/CMakeLists.txt b/sz/CMakeLists.txt index d8b8a4b6..b554bdf8 100644 --- a/sz/CMakeLists.txt +++ b/sz/CMakeLists.txt @@ -1,14 +1,18 @@ aux_source_directory(src sz_sources) add_library (SZ SHARED ${sz_sources}) -target_link_libraries (SZ ${ZLIB_LIBRARIES} ${ZSTD_LIBRARIES}) +target_link_libraries (SZ PRIVATE ${ZLIB_LIBRARIES} ${ZSTD_LIBRARIES}) if (UNIX) - target_link_libraries (SZ m) + target_link_libraries (SZ PUBLIC m) endif () target_compile_options(SZ PRIVATE $<$:-O3 -Wall -Wextra -Wpedantic -Wno-unused-parameter> ) +if (OPENMP_FOUND) + target_compile_options (SZ PRIVATE ${OpenMP_C_FLAGS}) + target_link_libraries (SZ PRIVATE ${OpenMP_C_LIBRARIES}) +endif () install (TARGETS SZ LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) From 250574d0d83f7d0ede2dc7ed4533483244fa5130 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Mon, 29 Jul 2019 18:34:29 +0200 Subject: [PATCH 2/2] Remove useless flags --- CMakeLists.txt | 4 +--- sz/CMakeLists.txt | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90d365a0..897d9ef2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,9 +11,7 @@ enable_testing() find_package (OpenMP REQUIRED) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=c99") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11") - +set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/sz/CMakeLists.txt b/sz/CMakeLists.txt index b554bdf8..6f5bf0af 100644 --- a/sz/CMakeLists.txt +++ b/sz/CMakeLists.txt @@ -6,9 +6,6 @@ if (UNIX) target_link_libraries (SZ PUBLIC m) endif () -target_compile_options(SZ - PRIVATE $<$:-O3 -Wall -Wextra -Wpedantic -Wno-unused-parameter> - ) if (OPENMP_FOUND) target_compile_options (SZ PRIVATE ${OpenMP_C_FLAGS}) target_link_libraries (SZ PRIVATE ${OpenMP_C_LIBRARIES})