Commit 1945731b authored by Marc Vef's avatar Marc Vef
Browse files

Refactored CXX compiler flags. Introduced new build types: Memcheck, Maintainer

Users may use -DCMAKE_CXX_FLAGS_DEBUG to add addition compiler flags for debug mode.
parent beb53d40
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -18,10 +18,12 @@ if (NOT CMAKE_BUILD_TYPE)
ENDIF (NOT CMAKE_BUILD_TYPE)
message("* Current daemon build type is : ${CMAKE_BUILD_TYPE}")

# Compiler flags for various cmake build types
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64 -O3")
# For debugging memory leaks.
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall --pedantic -g -pg -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall --pedantic -g -pg -no-pie -O0")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall --pedantic -g -O0")
set(CMAKE_CXX_FLAGS_MEMCHECK "-Wall --pedantic -g -O0 -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_MAINTAINER "-Wall --pedantic -g -O0 -pg -no-pie")
mark_as_advanced(CMAKE_CXX_FLAGS_MAINTAINER)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})

@@ -133,7 +135,7 @@ set(SOURCE_FILES main.cpp main.hpp include/configure.hpp configure_public.hpp ut
        include/rpc/rpc_utils.hpp src/rpc/rpc_utils.cpp include/global_defs.hpp)
add_executable(adafs_daemon ${SOURCE_FILES})

if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
if (${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
    target_link_libraries(adafs_daemon ${ROCKSDB_LIBRARIES}
            # rocksdb libs
            ${snappy_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${ZSTD_LIBRARIES} ${LZ4_LIBRARY} ${gflags_LIBRARIES}
@@ -147,5 +149,4 @@ else ()
            # margo libs
            ${NA_LIB} ${MERCURY_LIBRARIES} ${MERCURY_UTIL_LIBRARIES} ${ABT_LIBRARIES} ${ABT_SNOOZER_LIBRARIES} ${MARGO_LIBRARIES}
            -lpthread -lboost_system -lboost_filesystem -lboost_serialization -lboost_program_options)

endif ()
 No newline at end of file
+7 −4
Original line number Diff line number Diff line
@@ -2,10 +2,13 @@ cmake_minimum_required(VERSION 3.6)
project(preload CXX C)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -fPIC -O3")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall --pedantic -g -pg -fPIC -no-pie -O0")
message("* Current library build type is : ${CMAKE_BUILD_TYPE}")

# Compiler flags for various cmake build types
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fPIC")
set(CMAKE_CXX_FLAGS_MEMCHECK "-Wall --pedantic -g -O0 -fsanitize=address -fno-omit-frame-pointer -fPIC")
set(CMAKE_CXX_FLAGS_MAINTAINER "-Wall --pedantic -g -O0 -pg -no-pie -fPIC") # -no-pie to be tested with gprof
message("* Current library build type is : ${CMAKE_BUILD_TYPE}")

set(SOURCE_FILES_PRELOAD preload.cpp ../../include/configure.hpp ../../configure_public.hpp
        open_file_map.cpp ../../include/preload/preload.hpp
@@ -16,7 +19,7 @@ set(SOURCE_FILES_PRELOAD preload.cpp ../../include/configure.hpp ../../configure
        rpc/ld_rpc_data_ws.cpp rpc/ld_rpc_metadentry.cpp ../../include/preload/rpc/ld_rpc_data_ws.hpp ../../include/preload/rpc/ld_rpc_metadentry.hpp
        ../../include/rpc/rpc_utils.hpp ../rpc/rpc_utils.cpp intcp_functions.cpp passthrough.cpp ../../include/preload/passthrough.hpp ../../include/global_defs.hpp adafs_functions.cpp adafs_functions.cpp ../../include/preload/adafs_functions.hpp)
add_library(iointer SHARED ${SOURCE_FILES_PRELOAD})
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
if (${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
    target_link_libraries(iointer dl ${NA_LIB} ${MERCURY_LIBRARIES} ${MERCURY_UTIL_LIBRARIES} ${ABT_LIBRARIES}
            ${ABT_SNOOZER_LIBRARIES} ${MARGO_LIBRARIES}
            -lpthread -lboost_system -pg)