From 1a1482ef784e2e906dd59d1476447f7d92e925b2 Mon Sep 17 00:00:00 2001 From: Johannes Keller Date: Tue, 27 Aug 2024 09:25:15 +0200 Subject: [PATCH] update PDAF optimization flag setting Adapt flags according to 1. `CMAKE_CXX_COMPILER_ID` (`Intel` or `GNU`) 2. `CMAKE_BUILD_TYPE` (`RELEASE` or `DEBUG`) Flags are taken from TSMP1 `bldsva/intf_DA/pdaf/arch/build_interface_pdaf.ksh` --- cmake/BuildPDAF.cmake | 48 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/cmake/BuildPDAF.cmake b/cmake/BuildPDAF.cmake index 4879800..5b250ed 100644 --- a/cmake/BuildPDAF.cmake +++ b/cmake/BuildPDAF.cmake @@ -73,12 +73,48 @@ list(JOIN PDAF_LINK_LIBS " " PDAF_LINK_LIBS) # Set PDAF_OPTIM for Makefile header # ---------------------------------- -list(APPEND PDAF_OPTIM "-O2") -list(APPEND PDAF_OPTIM "-xHost") -list(APPEND PDAF_OPTIM "-r8") - -# For Gnu-compiler -# list(APPEND PDAF_OPTIM "-O2 -xHost -fbacktrace -fdefault-real-8 -falign-commons -fno-automatic -finit-local-zero -mcmodel=large") +if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + + # using Intel Compiler + if (CMAKE_BUILD_TYPE STREQUAL "RELEASE") + # Release optimization flags + list(APPEND PDAF_OPTIM "-O2") + elseif (CMAKE_BUILD_TYPE STREQUAL "DEBUG") + # Debug optimization flags + list(APPEND PDAF_OPTIM "-O0") + list(APPEND PDAF_OPTIM "-g") + list(APPEND PDAF_OPTIM "-traceback") + else() + message(FATAL_ERROR "Unsupported CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") + endif() + + list(APPEND PDAF_OPTIM "-xHost") + list(APPEND PDAF_OPTIM "-r8") + +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + + # using GCC (experimental) + if (CMAKE_BUILD_TYPE STREQUAL "RELEASE") + # Release optimization flags + list(APPEND PDAF_OPTIM "-O2") + elseif (CMAKE_BUILD_TYPE STREQUAL "DEBUG") + # Debug optimization flags + list(APPEND PDAF_OPTIM "-O0") + list(APPEND PDAF_OPTIM "-g") + list(APPEND PDAF_OPTIM "-fbacktrace") + else() + message(FATAL_ERROR "Unsupported CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") + endif() + + list(APPEND PDAF_OPTIM "-fdefault-real-8") + list(APPEND PDAF_OPTIM "-falign-commons") + list(APPEND PDAF_OPTIM "-fno-automatic") + list(APPEND PDAF_OPTIM "-finit-local-zero") + list(APPEND PDAF_OPTIM "-mcmodel=large") + +else() + message(FATAL_ERROR "Unsupported CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}") +endif() # Join list list(JOIN PDAF_OPTIM " " PDAF_OPTIM)