ovni/CMakeLists.txt

145 lines
3.6 KiB
CMake
Raw Normal View History

2021-11-03 08:47:02 +01:00
#
# Copyright (c) 2021 Barcelona Supercomputing Center (BSC)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.20)
2021-11-03 08:47:02 +01:00
project(OVNI LANGUAGES C)
add_compile_options(-Wall -Wextra -Wformat
-Wmissing-prototypes -Wstrict-prototypes
#-Wconversion -Wsign-conversion
-Wold-style-definition -pedantic
-Werror
)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_EXTENSIONS FALSE)
option(ENABLE_DEBUG_LOG "Enable debug messages (very verbose)")
if(ENABLE_DEBUG_LOG)
add_definitions(-DENABLE_DEBUG)
endif()
2021-11-18 14:52:03 +01:00
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
2021-11-19 17:41:10 +01:00
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel Asan UBsan." FORCE)
2021-11-18 14:52:03 +01:00
endif(NOT CMAKE_BUILD_TYPE)
2021-11-03 08:47:02 +01:00
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_available OUTPUT error LANGUAGES C)
# Enable IPO by default, if available
if(ipo_available)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(WARNING "IPO is not supported, expect performance penalty")
2021-11-03 08:47:02 +01:00
endif()
2021-11-18 14:52:03 +01:00
# Extra build type for AddressSanitizer (Asan)
set(CMAKE_C_FLAGS_ASAN "${CMAKE_C_FLAGS_DEBUG} \
-fsanitize=address \
-fno-optimize-sibling-calls \
-fsanitize-address-use-after-scope \
-fno-omit-frame-pointer"
CACHE STRING "Flags used by the C compiler during AddressSanitizer builds." FORCE)
2021-11-19 17:41:10 +01:00
set(CMAKE_C_FLAGS_UBSAN "${CMAKE_C_FLAGS_DEBUG} -fsanitize=undefined"
CACHE STRING "Flags used by the C compiler during UndefinedBehaviorSanitizer builds." FORCE)
2022-09-29 12:35:25 +02:00
# Required for clock_gettime() in glibc <= 2.17
include(CheckLibraryExists)
check_library_exists(c clock_gettime "" HAVE_CLOCK_GETTIME)
if (NOT HAVE_CLOCK_GETTIME)
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_RT)
if (HAVE_CLOCK_GETTIME_RT)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lrt")
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lrt")
else()
message(FATAL_ERROR "cannot find clock_gettime()")
endif()
endif()
2021-11-03 08:47:02 +01:00
add_library(ovni SHARED
ovni.c
parson.c
)
target_include_directories(ovni PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(ovniemu
2021-11-03 08:47:02 +01:00
chan.c
emu.c
emu_nosv.c
emu_openmp.c
emu_ovni.c
emu_tampi.c
2021-12-03 16:24:41 +01:00
emu_nodes.c
emu_kernel.c
2022-07-01 17:54:18 +02:00
emu_nanos6.c
emu_task.c
trace.c
2021-11-03 08:47:02 +01:00
ovni.c
parson.c
pcf.c
prv.c
)
add_executable(ovnidump
2021-11-03 08:47:02 +01:00
dump.c
ovni.c
trace.c
2021-11-03 08:47:02 +01:00
parson.c
)
add_executable(ovni2prv
ovni2prv.c
ovni.c
trace.c
2021-11-03 08:47:02 +01:00
parson.c
)
add_executable(ovnisort
sort.c
ovni.c
trace.c
parson.c
)
# Use <PackageName>_ROOT variables if available, commonly used by MPI
# installations
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
2021-11-03 08:47:02 +01:00
find_package(MPI REQUIRED)
add_executable(ovnisync ovnisync.c)
target_link_libraries(ovnisync m MPI::MPI_C)
2021-11-03 08:47:02 +01:00
2021-11-29 14:43:40 +01:00
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
endif()
install(TARGETS ovni LIBRARY DESTINATION lib)
install(TARGETS ovniemu ovnidump ovni2prv ovnisync ovnisort RUNTIME DESTINATION bin)
2021-11-03 08:47:02 +01:00
install(FILES ovni.h DESTINATION include)
install(DIRECTORY cfg/ DESTINATION share/ovni)