From 77236674e759fe0031f54d9154339922ca96ee14 Mon Sep 17 00:00:00 2001
From: Andrey Debolskiy <and.debol@gmail.com>
Date: Wed, 23 Oct 2024 17:12:50 +0300
Subject: [PATCH] fix compile flags

---
 CMakeLists.txt               | 22 ++++++++++++++++++++--
 config-parser/CMakeLists.txt | 13 +++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a023f2a..d206ec7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,7 +30,7 @@ if(BUILD_DOC)
         # option ALL allows to build the docs together with the code
         add_custom_target( doc_doxygen ALL
             COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_IN}
-            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) # WORKING_DIRECTORY: Execute the command with the given current working directory. If it is a relative path it will be interpreted relative to the build tree directory corresponding to the current source directory.
+            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
     else()
     message("Doxygen need to be installed to generate the doxygen documentation")
     endif (DOXYGEN_FOUND)
@@ -196,6 +196,8 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
     SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
     SET(CMAKE_C_ARCHIVE_FINISH   "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
     SET(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
+    SET(CMAKE_Fortran_ARCHIVE_FINISH   "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
+    SET(CMAKE_Fortran_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
 endif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
 # set(CMAKE_Fortran_ARCHIVE_FINISH  "$<CMAKE_RANLIB> -no_warning_for_no_symbols -c $<TARGET>")
 target_include_directories(sfx_lib PUBLIC ${CMAKE_BINARY_DIR}/modules/)
@@ -225,10 +227,26 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
         target_compile_options(sfx
             PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -traceback -check all -ftrapuv -debug all >)
     elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
-        target_compile_options(sfx-
+        target_compile_options(sfx
             PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -fbacktrace -ffpe-trap=zero,overflow,underflow >)
     endif()
 endif()
+if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
+    target_compile_options(sfx_lib
+            PUBLIC $<$<COMPILE_LANGUAGE:C>: -g >)
+    target_compile_options(sfx_lib
+            PUBLIC $<$<COMPILE_LANGUAGE:CXX>: -g >)
+    target_compile_options(sfx_lib
+            PUBLIC $<$<COMPILE_LANGUAGE:CUDA>: -g >)
+    if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
+        target_compile_options(sfx_lib
+                PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -traceback -check all -ftrapuv -debug all >)
+    elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+        target_compile_options(sfx_lib
+                PUBLIC $<$<COMPILE_LANGUAGE:Fortran>: -g -fbacktrace -ffpe-trap=zero,overflow,underflow >)
+    endif()
+endif()
+
 
 # copy data & configs on post build
 add_custom_command(
diff --git a/config-parser/CMakeLists.txt b/config-parser/CMakeLists.txt
index f5db371..ec02131 100644
--- a/config-parser/CMakeLists.txt
+++ b/config-parser/CMakeLists.txt
@@ -49,6 +49,19 @@ set(SOURCES_CXX ${SOURCES_CXX} ${SOURCES_C})
 set(HEADERS_CXX ${HEADERS_CXX})
 
 add_library(config_parser_CXX STATIC ${HEADERS_CXX} ${SOURCES_CXX})
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
+    target_compile_options(config_parser_CXX
+            PUBLIC $<$<COMPILE_LANGUAGE:CXX>: -restrict -alias-const -parallel -funroll-loops -no-ansi-alias >)
+elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "IntelLLVM")
+    target_compile_options(config_parser_CXX
+            PUBLIC $<$<COMPILE_LANGUAGE:CXX>: -no-ansi-alias -funroll-loops -Wno-tautological-constant-compare >)
+elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+    target_compile_options(config_parser_CXX
+            PUBLIC $<$<COMPILE_LANGUAGE:CXX>: -fno-strict-aliasing -funroll-loops >)
+endif()
+find_package(OpenMP REQUIRED)
+target_link_libraries(config_parser_CXX PUBLIC OpenMP::OpenMP_CXX)
 add_library(config_parser_F STATIC   ${SOURCES_F})
 set_property(TARGET config_parser_F PROPERTY LINKER_LANGUAGE Fortran)
 target_link_libraries(config_parser_F config_parser_CXX)
+
-- 
GitLab