From 31ed8ceac0793e362c10d920ea854a32a11cfb46 Mon Sep 17 00:00:00 2001 From: Alexander Vieth Date: Wed, 28 Aug 2024 15:46:41 +0200 Subject: [PATCH] CMake: rename options, add prefix --- CMakeLists.txt | 14 +++++++------- conanfile.py | 5 +++-- hdi/data/CMakeLists.txt | 8 ++++---- hdi/dimensionality_reduction/CMakeLists.txt | 8 ++++---- hdi/utils/CMakeLists.txt | 8 ++++---- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7dd9aeeb..6e86fc69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,22 +6,22 @@ PROJECT(${PROJECT}) # ----------------------------------------------------------------------------- # User Options # ----------------------------------------------------------------------------- -option(ENABLE_AVX "Enable AVX support" OFF) -option(ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build with MSVC" OFF) -option(ENABLE_PID "Set POSITION_INDEPENDENT_CODE property for all targets" OFF) -set(OPTIMIZATION_LEVEL "2" CACHE STRING "Optimization level for all targets in release builds, e.g. 0, 1, 2") +option(HDILib_ENABLE_AVX "Enable AVX support" OFF) +option(HDILib_ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build with MSVC" OFF) +option(HDILib_ENABLE_PID "Set POSITION_INDEPENDENT_CODE property for all targets" OFF) option(HDILib_INSTALL "Enable installation of the HDILib" ON) +set(HDILib_OPTIMIZATION_LEVEL "2" CACHE STRING "Optimization level for all targets in release builds, e.g. 0, 1, 2") set(HDILib_VERSION "undefined" CACHE STRING "HDILib Library version") -if (ENABLE_AVX) +if (HDILib_ENABLE_AVX) message("ENABLE_AVX is ON") endif() -if (ENABLE_CODE_ANALYSIS AND WIN32) +if (HDILib_ENABLE_CODE_ANALYSIS AND WIN32) message("Code Analysis ENABLED") endif() -if (ENABLE_PID) +if (HDILib_ENABLE_PID) message(STATUS "Position independent code compilation ON") endif() diff --git a/conanfile.py b/conanfile.py index dbe82b6b..c58d6c60 100644 --- a/conanfile.py +++ b/conanfile.py @@ -88,10 +88,11 @@ def generate(self): ) else: tc.variables["CMAKE_INSTALL_PREFIX"] = "${CMAKE_BINARY_DIR}" - tc.variables["ENABLE_CODE_ANALYSIS"] = "ON" tc.variables["CMAKE_VERBOSE_MAKEFILE"] = "ON" if os.getenv("Analysis", None) is None: - tc.variables["ENABLE_CODE_ANALYSIS"] = "OFF" + tc.variables["HDILib_ENABLE_CODE_ANALYSIS"] = "OFF" + else: + tc.variables["HDILib_ENABLE_CODE_ANALYSIS"] = "ON" tc.variables[ "CMAKE_MSVC_RUNTIME_LIBRARY" ] = "MultiThreaded$<$:Debug>DLL" diff --git a/hdi/data/CMakeLists.txt b/hdi/data/CMakeLists.txt index 22f3339b..833776da 100644 --- a/hdi/data/CMakeLists.txt +++ b/hdi/data/CMakeLists.txt @@ -16,18 +16,18 @@ if(OpenMP_CXX_FOUND) target_link_libraries(${PROJECT} PRIVATE OpenMP::OpenMP_CXX) endif() -if(ENABLE_PID) +if(HDILib_ENABLE_PID) set_target_properties(${PROJECT} PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() -if(ENABLE_CODE_ANALYSIS) +if(HDILib_ENABLE_CODE_ANALYSIS) if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") target_compile_options(${PROJECT} PRIVATE /analyze) endif() endif() -set_optimization_level(${PROJECT} ${OPTIMIZATION_LEVEL}) -check_and_set_AVX(${PROJECT} ${ENABLE_AVX}) +set_optimization_level(${PROJECT} ${HDILib_OPTIMIZATION_LEVEL}) +check_and_set_AVX(${PROJECT} ${HDILib_ENABLE_AVX}) ########### INSTALL ############## if(${HDILib_INSTALL}) diff --git a/hdi/dimensionality_reduction/CMakeLists.txt b/hdi/dimensionality_reduction/CMakeLists.txt index 17e71085..452e7e77 100644 --- a/hdi/dimensionality_reduction/CMakeLists.txt +++ b/hdi/dimensionality_reduction/CMakeLists.txt @@ -37,18 +37,18 @@ if(OpenMP_CXX_FOUND) target_link_libraries(${PROJECT} PRIVATE OpenMP::OpenMP_CXX) endif() -if(ENABLE_PID) +if(HDILib_ENABLE_PID) set_target_properties(${PROJECT} PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() -if(ENABLE_CODE_ANALYSIS) +if(HDILib_ENABLE_CODE_ANALYSIS) if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") target_compile_options(${PROJECT} PRIVATE /analyze) endif() endif() -set_optimization_level(${PROJECT} ${OPTIMIZATION_LEVEL}) -check_and_set_AVX(${PROJECT} ${ENABLE_AVX}) +set_optimization_level(${PROJECT} ${HDILib_OPTIMIZATION_LEVEL}) +check_and_set_AVX(${PROJECT} ${HDILib_ENABLE_AVX}) if(UNIX) set(THREADS_PREFER_PTHREAD_FLAG ON) diff --git a/hdi/utils/CMakeLists.txt b/hdi/utils/CMakeLists.txt index 018900d3..baf17bdf 100644 --- a/hdi/utils/CMakeLists.txt +++ b/hdi/utils/CMakeLists.txt @@ -14,18 +14,18 @@ if(OpenMP_CXX_FOUND) target_link_libraries(${PROJECT} PRIVATE OpenMP::OpenMP_CXX) endif() -if(ENABLE_PID) +if(HDILib_ENABLE_PID) set_target_properties(${PROJECT} PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() -if(ENABLE_CODE_ANALYSIS) +if(HDILib_ENABLE_CODE_ANALYSIS) if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") target_compile_options(${PROJECT} PRIVATE /analyze) endif() endif() -set_optimization_level(${PROJECT} ${OPTIMIZATION_LEVEL}) -check_and_set_AVX(${PROJECT} ${ENABLE_AVX}) +set_optimization_level(${PROJECT} ${HDILib_OPTIMIZATION_LEVEL}) +check_and_set_AVX(${PROJECT} ${HDILib_ENABLE_AVX}) if (UNIX) target_link_libraries (hdiutils PRIVATE ${CMAKE_DL_LIBS}) # glad.cpp requires -ldl