Ver código fonte

introduce some required cmake scripts

Sven Czarnian 3 anos atrás
pai
commit
27857b0369
4 arquivos alterados com 159 adições e 0 exclusões
  1. 8 0
      cmake/3rdParty.cmake
  2. 51 0
      cmake/3rdPartyTargets.cmake
  3. 49 0
      cmake/FindEuroScope.cmake
  4. 51 0
      cmake/Protobuf.cmake

+ 8 - 0
cmake/3rdParty.cmake

@@ -0,0 +1,8 @@
+# Author:
+#   Sven Czarnian <devel@svcz.de>
+# License:
+#   GPLv3
+# Brief:
+#   Creates the 3rd-party targets
+
+INCLUDE(${CMAKE_SOURCE_DIR}/cmake/3rdPartyTargets.cmake)

+ 51 - 0
cmake/3rdPartyTargets.cmake

@@ -0,0 +1,51 @@
+# Author:
+#   Sven Czarnian <devel@svcz.de>
+# License:
+#   GPLv3
+# Brief:
+#   Creates the 3rd-party import targets
+
+# include the external project library
+INCLUDE(ExternalProject)
+
+# define the import target of libsodium
+ADD_LIBRARY(libsodium STATIC IMPORTED)
+IF (MSVC)
+    SET_TARGET_PROPERTIES(libsodium PROPERTIES
+        IMPORTED_IMPLIB_DEBUG "${CMAKE_SOURCE_DIR}/external/lib/libsodiumd.lib"
+        IMPORTED_IMPLIB_RELEASE "${CMAKE_SOURCE_DIR}/external/lib/libsodium.lib"
+    )
+    TARGET_INCLUDE_DIRECTORIES(libsodium INTERFACE "${CMAKE_SOURCE_DIR}/external/include")
+ELSE ()
+    MESSAGE(FATAL_ERROR "Unsupported compiler")
+ENDIF ()
+
+# define the import target of libzmq
+ADD_LIBRARY(libzmq STATIC IMPORTED)
+ADD_DEPENDENCIES(libzmq libsodium)
+IF (MSVC)
+    SET_TARGET_PROPERTIES(libzmq PROPERTIES
+        IMPORTED_IMPLIB_DEBUG "${CMAKE_SOURCE_DIR}/external/lib/libzmqd.lib"
+        IMPORTED_IMPLIB_RELEASE "${CMAKE_SOURCE_DIR}/external/lib/libzmq.lib"
+    )
+    TARGET_INCLUDE_DIRECTORIES(libzmq INTERFACE "${CMAKE_SOURCE_DIR}/external/include")
+ELSE ()
+    MESSAGE(FATAL_ERROR "Unsupported compiler")
+ENDIF ()
+
+# define the import target of cppzmq
+ADD_LIBRARY(cppzmq INTERFACE)
+TARGET_INCLUDE_DIRECTORIES(cppzmq INTERFACE "${CMAKE_SOURCE_DIR}/external/include")
+ADD_DEPENDENCIES(cppzmq libzmq)
+
+# define the import target of protobuf
+ADD_LIBRARY(protobuf STATIC IMPORTED)
+IF (MSVC)
+    SET_TARGET_PROPERTIES(protobuf PROPERTIES
+        IMPORTED_LOCATION_DEBUG "${CMAKE_INSTALL_PREFIX}/lib/libprotobufd.lib"
+        IMPORTED_LOCATION_RELEASE "${CMAKE_INSTALL_PREFIX}/lib/libprotobuf.lib"
+    )
+    TARGET_INCLUDE_DIRECTORIES(protobuf INTERFACE "${CMAKE_INSTALL_PREFIX}/include")
+ELSE ()
+    MESSAGE(FATAL_ERROR "Unsupported compiler")
+ENDIF ()

+ 49 - 0
cmake/FindEuroScope.cmake

@@ -0,0 +1,49 @@
+# Author:
+#   Sven Czarnian <devel@svcz.de>
+# License:
+#   LGPLv3
+# Brief:
+#   Finds the EuroScope headers and libraries
+#   A target EuroScope will be created and the EuroScope_FOUND flag will be set
+
+IF(NOT TARGET EuroScope)
+    IF(NOT EuroScope_DIR)
+        MESSAGE(FATAL_ERROR "Please set EuroScope_DIR")
+        SET(EuroScope_DIR "EuroScope_DIR-NOTFOUND" CACHE PATH PARENT_SCOPE)
+    ENDIF()
+
+    FIND_FILE(EuroScope_EXECUTABLE
+        NAMES
+            EuroScope.exe
+        PATHS
+            ${EuroScope_DIR}
+    )
+    FIND_FILE(EuroScope_LIBRARY
+        NAMES
+            EuroScopePlugInDll.lib
+        PATHS
+            ${EuroScope_DIR}/PlugInEnvironment
+    )
+    FIND_PATH(EuroScope_INCLUDE_DIR
+        NAMES
+            EuroScopePlugIn.h
+        PATHS
+            ${EuroScope_DIR}/PlugInEnvironment
+    )
+
+    IF(NOT ${EuroScope_EXECUTABLE} STREQUAL "EuroScope_EXECUTABLE-NOTFOUND" AND
+       NOT ${EuroScope_LIBRARY} STREQUAL "EuroScope_LIBRARY-NOTFOUND" AND
+       NOT ${EuroScope_INCLUDE_DIR} STREQUAL "EuroScope_INCLUDE_DIR-NOTFOUND")
+        MESSAGE(STATUS "Found EuroScope-library:")
+        MESSAGE(STATUS "  ${EuroScope_LIBRARY}")
+        MESSAGE(STATUS "Found EuroScope-headers:")
+        MESSAGE(STATUS "  ${EuroScope_INCLUDE_DIR}")
+
+        ADD_LIBRARY(EuroScope INTERFACE IMPORTED GLOBAL)
+        TARGET_LINK_LIBRARIES(EuroScope INTERFACE ${EuroScope_LIBRARY})
+        TARGET_INCLUDE_DIRECTORIES(EuroScope INTERFACE ${EuroScope_INCLUDE_DIR})
+        SET(EuroScope_FOUND ON)
+    ENDIF()
+ELSE()
+    MESSAGE(STATUS "EuroScope is already included.")
+ENDIF()

+ 51 - 0
cmake/Protobuf.cmake

@@ -0,0 +1,51 @@
+# Author:
+#   Sven Czarnian <devel@svcz.de>
+# License:
+#   Closed Source
+# Brief:
+#   Defines the protobuf functions
+
+# Brief:
+#   Proto-files are compiled into C++ files
+# Parameters:
+#   PROTO_FILES      - The proto-files with the message description
+#   SOURCE_FILES     - Contains the filenames and paths of the generated files
+FUNCTION(ProtobufCompile PROTO_FILES SOURCE_FILES)
+    SET(GENERATED_FILES "")
+
+    FOREACH (PROTO ${PROTO_FILES})
+        # get the relevant information to configure the protoc-run
+        GET_FILENAME_COMPONENT(FILENAME ${PROTO} NAME_WLE)
+        GET_FILENAME_COMPONENT(DIRECTORY ${PROTO} DIRECTORY)
+
+        # define the output files
+        SET(CPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/protobuf/${FILENAME}.pb.cc)
+        SET(HPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/protobuf/${FILENAME}.pb.h)
+
+        # create the protoc-directory
+        FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/protobuf)
+
+        # define the protoc-command
+        ADD_CUSTOM_COMMAND(
+            OUTPUT ${CPP_FILE} ${HPP_FILE}
+            DEPENDS protobuf
+            COMMAND ${CMAKE_SOURCE_DIR}/external/bin/protoc.exe
+            ARGS -I=${DIRECTORY} --cpp_out=${CMAKE_CURRENT_BINARY_DIR}/protobuf ${PROTO}
+            WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}/bin"
+            COMMENT "Creating C++-sources for ${PROTO}"
+        )
+
+        # disable warnings
+        IF (MSVC)
+            SET_SOURCE_FILES_PROPERTIES(${CPP_FILE} PROPERTIES COMPILE_FLAGS "/wd4127 /wd5054 /wd4125 /wd4267")
+            SET_SOURCE_FILES_PROPERTIES(${HPP_FILE} PROPERTIES COMPILE_FLAGS "/wd4127 /wd5054 /wd4125 /wd4267")
+        ENDIF ()
+
+        # add the generated files
+        LIST(APPEND GENERATED_FILES ${CPP_FILE})
+        LIST(APPEND GENERATED_FILES ${HPP_FILE})
+    ENDFOREACH ()
+
+    # set the output variables
+    SET(${SOURCE_FILES} ${GENERATED_FILES} PARENT_SCOPE)
+ENDFUNCTION()