1project (mipi_syst_library) 2cmake_minimum_required (VERSION 2.8) 3enable_testing() 4 5set_property(GLOBAL PROPERTY USE_FOLDERS ON) 6set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "") 7 8find_package(Doxygen) 9 10if (NOT DEFINED SYST_CFG_CONFORMANCE_LEVEL) 11 message(WARNING "SYST_CFG_CONFORMANCE_LEVEL not set, defaulting to leval 30 (complete implementation)") 12else() 13 message(STATUS "Building for SyS-T conformance level ${SYST_CFG_CONFORMANCE_LEVEL}.") 14endif() 15# SYS-T API version settings 16# 17set(SYST_CFG_VERSION_MAJOR "1" CACHE STRING "Supported MIPI SyS-T major specification version.") 18set(SYST_CFG_VERSION_MINOR "0" CACHE STRING "Supported MIPI SyS-T minor specification version.") 19set(SYST_CFG_CONFORMANCE_LEVEL "30" CACHE STRING "Supported MIPI SyS-T API conformance level. (10=min, 20=low overhead, 30=complete)") 20 21# SYS-T Implementation patch level 22# 23set(SYST_CFG_VERSION_PATCH "0" CACHE PATH "SyS-T Library patch level.") 24 25 26 27# External build dependencies: 28# * Google Test https://github.com/google/googletest (for unit tests) 29# 30if (NOT DEFINED SYST_BUILD_GTEST_DIR) 31 get_filename_component(GTEST_DIR "${CMAKE_CURRENT_LIST_DIR}/../external/googletest/googletest" ABSOLUTE) 32endif() 33set(SYST_BUILD_GTEST_DIR "${GTEST_DIR}" CACHE PATH "Location of Google Test sources, which are needed for unit tests") 34if (NOT EXISTS "${SYST_BUILD_GTEST_DIR}/include/gtest/gtest.h") 35 message(WARNING 36 "SYST_BUILD_GTEST_DIR=${SYST_BUILD_GTEST_DIR} does not point to a Google Test source location. Unittests will not be build. Try running \n" 37 "git submodule update --init --recursive\n" 38 "to populate the external folder git submodules or change SYST_BUILD_GTEST_DIR to point to Google Test sources.") 39 set(BUILD_TEST "OFF") 40else() 41 set(BUILD_TEST "ON") 42endif() 43 44option(SYST_BUILD_DOC "Create documentation (requires Doxygen)" ${DOXYGEN_FOUND}) 45option(SYST_BUILD_TEST "Build unit test (requires GoogleTest)" ${BUILD_TEST}) 46option(SYST_BUILD_HW_CRC "Use CPU crc32 instruction support if supported by architecture." ON) 47 48if (NOT DEFINED SYST_BUILD_PLATFORM_NAME) 49 set (SYST_BUILD_PLATFORM_NAME "example" CACHE STRING "Directory name of platform specific source code") 50 message(WARNING "SYST_BUILD_PLATFORM_NAME directory name variable is not set, using 'example' as default.") 51endif() 52 53 54# HW CRC support enabling 55# 56if (SYST_BUILD_HW_CRC) 57 if (CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86|x86_64.*|i?86.*|AMD64.*") 58 add_definitions(-D MIPI_SYST_CRC_INTRINSIC_ON) 59 message(STATUS "Enabling x86 crc32 CPU instruction support (SSE 4.2). Unset SYST_BUILD_HW_CRC to disable." ) 60 if (NOT WIN32) 61 add_definitions(-msse4.2) 62 endif() 63 endif() 64endif() 65 66configure_file(include/mipi_syst.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/mipi_syst.h) 67 68set (mipi_syst_Includes 69 include/mipi_syst.h.in 70 include/mipi_syst/api.h 71 include/mipi_syst/compiler.h 72 include/mipi_syst/crc32.h 73 include/mipi_syst/message.h 74 include/mipi_syst/inline.h 75) 76 77set (mipi_syst_Sources 78 src/mipi_syst_api.c 79 src/mipi_syst_compiler.c 80 src/mipi_syst_crc32.c 81 src/mipi_syst_init.c 82 src/mipi_syst_inline.c 83 src/mipi_syst_writer.c 84) 85 86set (mipi_syst_Platform_inc platform/${SYST_BUILD_PLATFORM_NAME}/include) 87set (mipi_syst_Platform_src platform/${SYST_BUILD_PLATFORM_NAME}/src/mipi_syst_platform.c) 88 89file(GLOB mipi_syst_Platform_includes "${mipi_syst_Platform_inc}/*.h") 90 91include_directories( 92 ${mipi_syst_Platform_inc} 93 ${CMAKE_CURRENT_BINARY_DIR}/include 94 include 95) 96 97add_library(mipi_syst 98 SHARED 99 ${mipi_syst_Platform_includes} 100 ${mipi_syst_Includes} 101 ${mipi_syst_Sources} 102 ${mipi_syst_Platform_src} 103) 104 105add_library(mipi_syst_static 106 STATIC 107 ${mipi_syst_Platform_includes} 108 ${mipi_syst_Includes} 109 ${mipi_syst_Sources} 110 ${mipi_syst_Platform_src} 111) 112 113set_target_properties(mipi_syst PROPERTIES 114 VERSION ${SYST_CFG_VERSION_MAJOR}.${SYST_CFG_VERSION_MINOR}.${SYST_CFG_VERSION_PATCH} 115 COMPILE_FLAGS "-DMIPI_SYST_EXPORTS" 116 FOLDER "Instrumentation Library" 117) 118 119set_target_properties(mipi_syst_static PROPERTIES 120 VERSION ${SYST_CFG_VERSION_MAJOR}.${SYST_CFG_VERSION_MINOR}.${SYST_CFG_VERSION_PATCH} 121 COMPILE_FLAGS "-DMIPI_SYST_STATIC" 122 FOLDER "Instrumentation Library" 123) 124 125install(TARGETS mipi_syst mipi_syst_static 126 RUNTIME DESTINATION bin 127 LIBRARY DESTINATION lib 128 ARCHIVE DESTINATION lib 129) 130 131install(DIRECTORY include/mipi_syst DESTINATION include) 132install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ DESTINATION include) 133install(DIRECTORY ${mipi_syst_Platform_inc}/ DESTINATION include) 134 135add_subdirectory(doxygen) 136add_subdirectory(test) 137