Skip to content

Commit

Permalink
CMake: rename options, add prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
alxvth committed Aug 28, 2024
1 parent 109e2c3 commit 31ed8ce
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
5 changes: 3 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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$<$<CONFIG:Debug>:Debug>DLL"
Expand Down
8 changes: 4 additions & 4 deletions hdi/data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
8 changes: 4 additions & 4 deletions hdi/dimensionality_reduction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions hdi/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 31ed8ce

Please sign in to comment.