Skip to content

Commit

Permalink
Cleanup CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
szmyd committed Oct 18, 2023
1 parent 53ff385 commit a2fb770
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 36 deletions.
59 changes: 27 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
cmake_minimum_required (VERSION 3.11)
project (homeobject)
project (homeobject LANGUAGES CXX)

include (cmake/Flags.cmake)
set(CMAKE_CXX_STANDARD 20)

if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
Expand All @@ -11,53 +10,49 @@ else ()
message("The file conanbuildinfo.cmake doesn't exist, some properties will be unavailable")
endif ()

if (NOT DEFINED BUILD_COVERAGE)
set(BUILD_COVERAGE OFF)
endif()
if (NOT DEFINED CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Debug")
endif()
if (DEFINED BUILD_COVERAGE)
if (${BUILD_COVERAGE})
include (cmake/CodeCoverage.cmake)
APPEND_COVERAGE_COMPILER_FLAGS()
endif ()
endif ()

if (NOT DEFINED MEMORY_SANITIZER_ON)
set(MEMORY_SANITIZER_ON OFF)
endif()
if (${MEMORY_SANITIZER_ON})
include (cmake/mem_sanitizer.cmake)
message(STATUS "********* WARNING: Running with Memory Sanitizer ON *********")
include (cmake/Flags.cmake)
if (BUILD_TESTING)
enable_testing()
if ((DEFINED CODE_COVERAGE) AND (${CODE_COVERAGE}))
include (cmake/CodeCoverage.cmake)
APPEND_COVERAGE_COMPILER_FLAGS()
elseif ((DEFINED MEMORY_SANITIZER_ON) AND (${MEMORY_SANITIZER_ON}))
message(WARNING "********* Running with Memory Sanitizer *********")
add_flags("-fsanitize=address \
-fsanitize=undefined \
-fsanitize-address-use-after-scope \
-fno-sanitize=alignment \
-DCDS_ADDRESS_SANITIZER_ENABLED \
-fno-omit-frame-pointer \
-fno-optimize-sibling-calls "
)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -fsanitize=undefined")
endif()
find_package(GTest QUIET REQUIRED)
endif()

find_program(CCACHE_FOUND ccache)
find_program(CCACHE_FOUND ccache QUIET)
if (CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif ()

if (BUILD_TESTING)
enable_testing()
endif()

# add conan information
# add component version information
add_flags("-DPACKAGE_NAME=${PROJECT_NAME}")
if (DEFINED CONAN_PACKAGE_VERSION)
message("Package Version: [${CONAN_PACKAGE_VERSION}]")
add_flags("-DPACKAGE_VERSION=\\\"${CONAN_PACKAGE_VERSION}\\\"")
else ()
message("Unknown Package Version")
add_flags("-DPACKAGE_VERSION=\\\"${CONAN_PACKAGE_VERSION}\\\"")
if (NOT DEFINED CONAN_PACKAGE_VERSION)
set(CONAN_PACKAGE_VERSION "0.0.0")
endif ()
add_flags("-DPACKAGE_VERSION=${CONAN_PACKAGE_VERSION}")

add_subdirectory(src)

# build info
string(TOUPPER "${CMAKE_BUILD_TYPE}" UC_CMAKE_BUILD_TYPE)
message(STATUS "Build configuration: ${CMAKE_BUILD_TYPE}")
message(STATUS "C compiler info: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION} ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}")
message(STATUS "C++ compiler info: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} ${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}")
message(STATUS "C flags: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${UC_CMAKE_BUILD_TYPE}}")
message(STATUS "C++ flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UC_CMAKE_BUILD_TYPE}}")
Expand Down
2 changes: 0 additions & 2 deletions cmake/mem_sanitizer.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def build(self):
if self.options.sanitize:
definitions['MEMORY_SANITIZER_ON'] = 'ON'
elif self.options.coverage:
definitions['BUILD_COVERAGE'] = 'ON'
definitions['CODE_COVERAGE'] = 'ON'

cmake = CMake(self)
cmake.configure(defs=definitions)
Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ cmake_minimum_required (VERSION 3.11)
find_package(Threads QUIET REQUIRED)
find_package(sisl QUIET REQUIRED)
find_package(homestore QUIET REQUIRED)
find_package(GTest QUIET REQUIRED)

link_directories(${spdk_LIB_DIRS} ${dpdk_LIB_DIRS})

Expand Down

0 comments on commit a2fb770

Please sign in to comment.