Add cmake support

This commit is contained in:
Rodrigo Arias 2021-11-03 08:47:02 +01:00
parent dc6713f75c
commit 623a938b1a
3 changed files with 95 additions and 39 deletions

13
.gitignore vendored
View File

@ -13,3 +13,16 @@
*.pcf *.pcf
*.png *.png
*.svg *.svg
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
DartConfiguration.tcl

82
CMakeLists.txt Normal file
View File

@ -0,0 +1,82 @@
#
# 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.10)
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)
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\n${error}")
endif()
add_library(ovni SHARED
ovni.c
parson.c
)
target_include_directories(ovni PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(emu
chan.c
emu.c
emu_nosv.c
emu_openmp.c
emu_ovni.c
emu_tampi.c
emu_nanos6.c
ovni.c
parson.c
pcf.c
prv.c
)
add_executable(dump
dump.c
ovni.c
parson.c
)
add_executable(ovni2prv
ovni2prv.c
ovni.c
parson.c
)
find_package(MPI REQUIRED)
add_executable(ovnisync ovnisync.c)
target_include_directories(ovnisync PRIVATE ${MPI_C_INCLUDE_PATH})
target_compile_options(ovnisync PRIVATE ${MPI_C_COMPILE_FLAGS})
target_link_libraries(ovnisync m ${MPI_C_LIBRARIES} ${MPI_C_LINK_FLAGS})
install(TARGETS ovni LIBRARY)
install(TARGETS emu dump ovni2prv ovnisync RUNTIME)
install(FILES ovni.h DESTINATION include)

View File

@ -1,39 +0,0 @@
CFLAGS=-fPIC
CFLAGS+=-std=c11 -pedantic -Werror -Wformat
CFLAGS+=-Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition
# Debug flags
#CFLAGS+=-fsanitize=address
#LDFLAGS+=-fsanitize=address
#CFLAGS+=-g -O0
#CFLAGS+=-DENABLE_DEBUG
#CFLAGS+=-fno-omit-frame-pointer
# Performance flags
CFLAGS+=-O3
CFLAGS+=-fstack-protector-explicit
CFLAGS+=-flto
BIN=dump test_speed ovni2prv emu libovni.so ovnisync
all: $(BIN)
libovni.a: ovni.o
ar -crs $@ $^
dump: ovni.o dump.o parson.o
test_speed: test_speed.c ovni.o parson.o
emu: emu.o emu_ovni.o emu_nosv.o emu_tampi.o emu_openmp.o emu_nanos6.o ovni.o prv.o pcf.o parson.o chan.o
libovni.so: ovni.o parson.o
$(LINK.c) -shared $^ -o $@
ovni2prv: ovni2prv.c ovni.o parson.o
ovnisync: ovnisync.c
mpicc $(CFLAGS) $(LDFLAGS) -lm $^ -o $@
clean:
rm -f *.o $(BIN)