From d24b6ea344fdac918db953dfc012d5d6df0d44bb Mon Sep 17 00:00:00 2001 From: Krishna Vedala Date: Tue, 7 Apr 2020 00:24:13 -0400 Subject: [PATCH] added option to enable or disable use of openmp --- CMakeLists.txt | 7 ++++++- project_euler/CMakeLists.txt | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 702ef7e7..6c8b0795 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ project(Algorithms_in_C DESCRIPTION "Set of algorithms implemented in C." ) +option(USE_OPENMP "flag to use OpenMP for multithreading" ON) + add_subdirectory(function_timer EXCLUDE_FROM_ALL) include_directories(function_timer/include) # link_libraries(function_timer) @@ -13,8 +15,11 @@ include_directories(function_timer/include) add_subdirectory(conversions) add_subdirectory(misc) +add_subdirectory(project_euler) -find_package(OpenMP) +if(USE_OPENMP) + find_package(OpenMP) +endif() set(CPACK_PROJECT_NAME ${PROJECT_NAME}) set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) diff --git a/project_euler/CMakeLists.txt b/project_euler/CMakeLists.txt index 234069e8..abb40df5 100644 --- a/project_euler/CMakeLists.txt +++ b/project_euler/CMakeLists.txt @@ -1,3 +1,7 @@ +if(USE_OPENMP) + find_package(OpenMP) +endif() + # If necessary, use the RELATIVE flag, otherwise each source file may be listed # with full pathname. RELATIVE may makes it easier to extract an executable name # automatically.