X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=CMakeLists.txt;h=8970eb5675efafd2ed7bef8e146fe55bb004c742;hb=9e23caa4c56259044604c38f107f7c637001b846;hp=f69386bf04259c02bf5369e67c25cc720425b352;hpb=ffe4aff87cc3a15863c09aa808adf2381c8f2fb7;p=apps%2Fagl-service-can-low-level.git diff --git a/CMakeLists.txt b/CMakeLists.txt index f69386bf..8970eb56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,90 +1,23 @@ -cmake_minimum_required(VERSION 2.8) - -project(nanopb C) - -set(nanopb_VERSION_STRING nanopb-0.3.8-dev) - -string(REPLACE "nanopb-" "" nanopb_VERSION ${nanopb_VERSION_STRING}) - -option(nanopb_BUILD_RUNTIME "Build the headers and libraries needed at runtime" ON) -option(nanopb_BUILD_GENERATOR "Build the protoc plugin for code generation" ON) -option(nanopb_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON) - -if(NOT DEFINED CMAKE_DEBUG_POSTFIX) - set(CMAKE_DEBUG_POSTFIX "d") -endif() - -include(GNUInstallDirs) - -if(MSVC AND nanopb_MSVC_STATIC_RUNTIME) - foreach(flag_var - CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) - if(${flag_var} MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - endif(${flag_var} MATCHES "/MD") - endforeach(flag_var) -endif() - -if(NOT DEFINED CMAKE_INSTALL_CMAKEDIR) - set(CMAKE_INSTALL_CMAKEDIR "lib/cmake/nanopb") -endif() - -if(nanopb_BUILD_GENERATOR) - set(generator_protos nanopb plugin) - - find_package(PythonInterp 2.7 REQUIRED) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c - "from distutils import sysconfig; print(sysconfig.get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}'))" - OUTPUT_VARIABLE PYTHON_INSTDIR - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - foreach(generator_proto IN LISTS generator_protos) - string(REGEX REPLACE "([^;]+)" "generator/proto/\\1.proto" generator_proto_file "${generator_proto}") - string(REGEX REPLACE "([^;]+)" "\\1_pb2.py" generator_proto_py_file "${generator_proto}") - add_custom_command( - OUTPUT ${generator_proto_py_file} - COMMAND protoc --python_out=${CMAKE_CURRENT_BINARY_DIR} -Igenerator/proto ${generator_proto_file} - DEPENDS ${generator_proto_file} - ) - add_custom_target("generate_${generator_proto_py_file}" ALL DEPENDS ${generator_proto_py_file}) - install( - FILES ${generator_proto_py_file} - DESTINATION ${PYTHON_INSTDIR} - ) - endforeach() -endif() - -if(nanopb_BUILD_RUNTIME) - add_library(protobuf-nanopb STATIC - pb.h - pb_common.h - pb_common.c - pb_encode.h - pb_encode.c - pb_decode.h - pb_decode.c) - - target_include_directories(protobuf-nanopb INTERFACE - $ - ) - - configure_file(extra/nanopb-config-version.cmake.in - nanopb-config-version.cmake @ONLY) - - install(TARGETS protobuf-nanopb EXPORT nanopb-targets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - - install(EXPORT nanopb-targets - DESTINATION ${CMAKE_INSTALL_CMAKEDIR} - NAMESPACE nanopb::) - - install(FILES extra/nanopb-config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/nanopb-config-version.cmake - DESTINATION ${CMAKE_INSTALL_CMAKEDIR}) - - install(FILES pb.h pb_common.h pb_encode.h pb_decode.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -endif() +########################################################################### +# Copyright 2015 - 2018 IoT.bzh +# +# author: Romain Forlot +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +CMAKE_MINIMUM_REQUIRED(VERSION 3.3) + +include(CTest) +enable_testing() +include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake)