From f78310f4886bad7029cc039971159ab7a97e00af Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Thu, 11 Feb 2016 15:50:16 +0100 Subject: Initial build infrastructure Contains the initial build infrastructure. Cmake was chosen for portability reasons. --- .gitignore | 1 + CMakeLists.txt | 69 ++++++++++++++++++++++++++++++++++++++++ README | 3 ++ cmake/CompilerUtils.cmake | 15 +++++++++ cmake/GitVersionGen.cmake | 43 +++++++++++++++++++++++++ cmake/MacroAddCompileFlags.cmake | 19 +++++++++++ cmake/cmake_uninstall.cmake.in | 21 ++++++++++++ include/CMakeLists.txt | 1 + include/ouroboros/CMakeLists.txt | 6 ++++ ouroboros.pc.in | 12 +++++++ src/CMakeLists.txt | 4 +++ src/da/CMakeLists.txt | 16 ++++++++++ src/da/main.c | 8 +++++ src/ipcp/CMakeLists.txt | 16 ++++++++++ src/ipcp/main.c | 8 +++++ src/irm/CMakeLists.txt | 16 ++++++++++ src/irm/main.c | 8 +++++ src/lib/CMakeLists.txt | 14 ++++++++ src/lib/cdap.c | 0 tests/CMakeLists.txt | 0 20 files changed, 280 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 README create mode 100644 cmake/CompilerUtils.cmake create mode 100644 cmake/GitVersionGen.cmake create mode 100644 cmake/MacroAddCompileFlags.cmake create mode 100644 cmake/cmake_uninstall.cmake.in create mode 100644 include/CMakeLists.txt create mode 100644 include/ouroboros/CMakeLists.txt create mode 100644 ouroboros.pc.in create mode 100644 src/CMakeLists.txt create mode 100644 src/da/CMakeLists.txt create mode 100644 src/da/main.c create mode 100644 src/ipcp/CMakeLists.txt create mode 100644 src/ipcp/main.c create mode 100644 src/irm/CMakeLists.txt create mode 100644 src/irm/main.c create mode 100644 src/lib/CMakeLists.txt create mode 100644 src/lib/cdap.c create mode 100644 tests/CMakeLists.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e4e5f6c8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..1c96ce66 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,69 @@ +cmake_minimum_required(VERSION 3.1.0) + +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") +#set(CMAKE_VERBOSE_MAKEFILE ON) + +project(ouroboros) + +include(GitVersionGen) +GIT_VERSION_GEN() + +include(GNUInstallDirs) + +set(PACKAGE_NAME "${CMAKE_PROJECT_NAME}") +set(PACKAGE_DESCRIPTION "The Ouroboros prototype" + CACHE STRING "Package description") +set(PACKAGE_URL "None" + CACHE STRING "Package URL") +set(PACKAGE_BUGREPORT "None" + CACHE STRING "Packaged bug-report email") +set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}" + CACHE STRING "Package version") + +message(STATUS "Package name is: ${PACKAGE_NAME}") +message(STATUS "Package description is: ${PACKAGE_DESCRIPTION}") +message(STATUS "Package version is: ${PACKAGE_VERSION}") +message(STATUS "Package URL is: ${PACKAGE_URL}") +message(STATUS "Package bug-report address: ${PACKAGE_BUGREPORT}") +message(STATUS "Package install prefix: ${CMAKE_INSTALL_PREFIX}") + +include(FindPkgConfig) + +include(CompilerUtils) +test_and_set_cxx_compiler_flag_global(-Wall) +test_and_set_cxx_compiler_flag_global(-Werror) +test_and_set_cxx_compiler_flag_global(-Wundef) +test_and_set_cxx_compiler_flag_global(-fmax-errors=1) + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/ouroboros.pc.in" + "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.pc" + @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.pc" + DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig") + +add_subdirectory(include) +add_subdirectory(src) +add_subdirectory(tests) + +include(FeatureSummary) +print_enabled_features() + +# Uninstall target +configure_file( + "${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" + "${CMAKE_BINARY_DIR}/cmake/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + +add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake/cmake_uninstall.cmake) + +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE_DESCRIPTION}") +set(CPACK_PACKAGE_VENDOR "Unknown") +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +set(CPACK_PACKAGE_VERSION_MAJOR "${PACKAGE_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${PACKAGE_VERSION_MINOR}") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") + +include(CPack) diff --git a/README b/README new file mode 100644 index 00000000..bbeb5750 --- /dev/null +++ b/README @@ -0,0 +1,3 @@ +This is the repository holding the Ouroboros prototype. Ouroboros is +an implementation of the Recursive InterNetwork Architecture. For more +information please refer to the doc/ folder. \ No newline at end of file diff --git a/cmake/CompilerUtils.cmake b/cmake/CompilerUtils.cmake new file mode 100644 index 00000000..99d9b662 --- /dev/null +++ b/cmake/CompilerUtils.cmake @@ -0,0 +1,15 @@ +include(CheckCXXCompilerFlag) + +function(test_and_set_cxx_compiler_flag_global _flag) + + string(REGEX REPLACE "-" "_" _sflag ${_flag}) + check_cxx_compiler_flag(${_flag} COMPILER_SUPPORTS_FLAG_${_sflag}) + + if(COMPILER_SUPPORTS_FLAG_${_sflag}) + message(STATUS "Compiler supports flag ${_flag}, added globally") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}" PARENT_SCOPE) + else(${_retval}) + message(STATUS "Compiler does not support flag ${_flag}, discarded") + endif() + +endfunction(test_and_set_cxx_compiler_flag_global) diff --git a/cmake/GitVersionGen.cmake b/cmake/GitVersionGen.cmake new file mode 100644 index 00000000..53ac166d --- /dev/null +++ b/cmake/GitVersionGen.cmake @@ -0,0 +1,43 @@ +macro(GIT_VERSION_GEN) + +include(FindGit) +if(NOT GIT_FOUND) + message(FATAL_ERROR "This is not a git repository") +endif() + +find_program(SORT "sort") +mark_as_advanced(SORT) +if (${SORT} STREQUAL "") + message(FATAL_ERROR "Cannot find the sort executable") +endif() + +find_program(TAIL "tail") +mark_as_advanced(TAIL) +if (${TAIL} STREQUAL "") + message(FATAL_ERROR "Cannot find the tail executable") +endif() + +execute_process( + COMMAND ${GIT_EXECUTABLE} tag -l -n0 + COMMAND ${SORT} -V + COMMAND ${TAIL} -n 1 + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE _git_tag + RESULT_VARIABLE _git_result + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT ${_git_result} EQUAL 0) + message(FATAL_ERROR "Cannot fetch repository tag") +endif() +message(STATUS "Repository tag is: ${_git_tag}") + +string(REGEX REPLACE + "[^0-9]*([0-9]+)\\.[0-9]+.*" "\\1" + _version_major "${_git_tag}") +string(REGEX REPLACE + "[^0-9]*[0-9]+\\.([0-9]+).*" "\\1" + _version_minor "${_git_tag}") + +set(PACKAGE_VERSION_MAJOR "${_version_major}") +set(PACKAGE_VERSION_MINOR "${_version_minor}") + +endmacro(GIT_VERSION_GEN) diff --git a/cmake/MacroAddCompileFlags.cmake b/cmake/MacroAddCompileFlags.cmake new file mode 100644 index 00000000..41f3797c --- /dev/null +++ b/cmake/MacroAddCompileFlags.cmake @@ -0,0 +1,19 @@ +# - MACRO_ADD_COMPILE_FLAGS(<_target> "flags...") + +# Copyright (c) 2006, Oswald Buddenhagen, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +macro(MACRO_ADD_COMPILE_FLAGS _target _flg) + + get_target_property(_flags ${_target} COMPILE_FLAGS) + if (_flags) + set(_flags "${_flags} ${_flg}") + else (_flags) + set(_flags "${_flg}") + endif (_flags) + set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "${_flags}") + +endmacro(MACRO_ADD_COMPILE_FLAGS) diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in new file mode 100644 index 00000000..4c07dc7b --- /dev/null +++ b/cmake/cmake_uninstall.cmake.in @@ -0,0 +1,21 @@ +if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") +endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + +file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +foreach(file ${files}) + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + exec_program( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif(NOT "${rm_retval}" STREQUAL 0) + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 00000000..8895c582 --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(ouroboros) diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt new file mode 100644 index 00000000..b4f04cf2 --- /dev/null +++ b/include/ouroboros/CMakeLists.txt @@ -0,0 +1,6 @@ +file(GLOB_RECURSE HEADER_FILES *.h) + +install(FILES ${HEADER_FILES} + DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/ouroboros) + +add_custom_target(qtcreator-workaround SOURCES ${HEADER_FILES}) diff --git a/ouroboros.pc.in b/ouroboros.pc.in new file mode 100644 index 00000000..b10ce9a4 --- /dev/null +++ b/ouroboros.pc.in @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${exec_prefix}/lib@LIB_SUFFIX@ +includedir=${prefix}/include + +Name: @PROJECT_NAME@ +Description: @PACKAGE_DESCRIPTION@ +URL: @PACKAGE_URL@ +Version: @PACKAGE_VERSION@ + +Libs: -L${libdir} -louroboros +Cflags: -I${includedir} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..ca434d8a --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(ipcp) +add_subdirectory(irm) +add_subdirectory(da) +add_subdirectory(lib) diff --git a/src/da/CMakeLists.txt b/src/da/CMakeLists.txt new file mode 100644 index 00000000..050b0f80 --- /dev/null +++ b/src/da/CMakeLists.txt @@ -0,0 +1,16 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +include_directories(${CMAKE_SOURCE_DIR}/include) +include_directories(${CMAKE_BINARY_DIR}/include) + +set(SOURCE_FILES + # Add source files here + main.c +) + +add_executable (da ${SOURCE_FILES}) + +target_link_libraries (da LINK_PUBLIC ouroboros) + +install(TARGETS da RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) diff --git a/src/da/main.c b/src/da/main.c new file mode 100644 index 00000000..2eeb7b36 --- /dev/null +++ b/src/da/main.c @@ -0,0 +1,8 @@ +#include + +int main() +{ + printf("Test of the DA\n"); + + return 0; +} diff --git a/src/ipcp/CMakeLists.txt b/src/ipcp/CMakeLists.txt new file mode 100644 index 00000000..845f5b7b --- /dev/null +++ b/src/ipcp/CMakeLists.txt @@ -0,0 +1,16 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +include_directories(${CMAKE_SOURCE_DIR}/include) +include_directories(${CMAKE_BINARY_DIR}/include) + +set(SOURCE_FILES + # Add source files here + main.c +) + +add_executable (ipcp ${SOURCE_FILES}) + +target_link_libraries (ipcp LINK_PUBLIC ouroboros) + +install(TARGETS ipcp RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) diff --git a/src/ipcp/main.c b/src/ipcp/main.c new file mode 100644 index 00000000..19397260 --- /dev/null +++ b/src/ipcp/main.c @@ -0,0 +1,8 @@ +#include + +int main() +{ + printf("Test of the IPCP\n"); + + return 0; +} diff --git a/src/irm/CMakeLists.txt b/src/irm/CMakeLists.txt new file mode 100644 index 00000000..82c73e38 --- /dev/null +++ b/src/irm/CMakeLists.txt @@ -0,0 +1,16 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +include_directories(${CMAKE_SOURCE_DIR}/include) +include_directories(${CMAKE_BINARY_DIR}/include) + +set(SOURCE_FILES + # Add source files here + main.c +) + +add_executable (irm ${SOURCE_FILES}) + +target_link_libraries (irm LINK_PUBLIC ouroboros) + +install(TARGETS irm RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) diff --git a/src/irm/main.c b/src/irm/main.c new file mode 100644 index 00000000..6388427f --- /dev/null +++ b/src/irm/main.c @@ -0,0 +1,8 @@ +#include + +int main() +{ + printf("Test of the IRM\n"); + + return 0; +} diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt new file mode 100644 index 00000000..5099fa48 --- /dev/null +++ b/src/lib/CMakeLists.txt @@ -0,0 +1,14 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +include_directories(${CMAKE_SOURCE_DIR}/include) +include_directories(${CMAKE_BINARY_DIR}/include) + +set(SOURCE_FILES + # Add source files here + cdap.c +) + +add_library(ouroboros SHARED ${SOURCE_FILES}) + +install(TARGETS ouroboros LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) diff --git a/src/lib/cdap.c b/src/lib/cdap.c new file mode 100644 index 00000000..e69de29b diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..e69de29b -- cgit v1.2.3