message("compile mode: 0, full build; 1, daily build")
message("current mode: ${compile_mode}")
set(CANBUS_MASTER_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if(${compile_mode})
CMAKE_MINIMUM_REQUIRED(VERSION 3.15)
project(CpApCanbus)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_BUILD_TYPE Release)
set(USE_STATIC_COMPILE ON)
if(USE_STATIC_COMPILE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g ")
add_definitions(-DSTATIC_COMPILE)
else()
if(USE_CC_QNX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -fPIC ")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -fPIC -ldl ")
endif()
endif()
message("moulde link flag is ${CMAKE_MODULE_LINKER_FLAGS} ")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-E -rdynamic")
message("shared link flags is ${CMAKE_SHARED_LINKER_FLAGS} ")
message("static link flag is ${CMAKE_STATIC_LINKER_FLAGS} ")
set(CALMCAR_MASTER_ROOT ${PROJECT_SOURCE_DIR})
message(STATUS "${PROJECT_NAME}'s ROOT is ${CALMCAR_MASTER_ROOT}")
include_directories(${CALMCAR_MASTER_ROOT})
set(PLATFORM_PATH ${CALMCAR_MASTER_ROOT}/platform)
set(CALMCAR_MASTER_3RDPARTY_LIBS_DIR ${CALMCAR_MASTER_ROOT}/03_thirdparty)
set(CALMCAR_MASTER_3RDPARTY_LIBS_DIR_ZHT ${CALMCAR_MASTER_ROOT}/03_thirdparty_ZHT)
set(CALMCAR_MASTER_INTERFACES ${CALMCAR_MASTER_ROOT}/08_interfaces)
message("use_cc_QNX: ${USE_CC_QNX}")
message("use_STATIC_COMPILE: ${USE_STATIC_COMPILE}")
if(USE_CC_QNX)
message(STATUS "================ -] building QNX-AARACH64 [- ================")
elseif(USE_CC_X86)
message(STATUS "================ -] building X86-UBUNTU [- ================")
ADD_DEFINITIONS(-DUSE_X86_UBUNTU=1)
# set cross-compiled `protobuf3.6.1` header files
set(PROTOBUF3_INSTALL_X86 ${CALMCAR_MASTER_3RDPARTY_LIBS_DIR}/x86)
include_directories(${PROTOBUF3_INSTALL_X86}/include)
link_directories(${PROTOBUF3_INSTALCALMCARL_X86}/lib)
# set cross-compiled `DDS` header files
set(DDS_INSTALL_X86 ${CALMCAR_MASTER_3RDPARTY_LIBS_DIR}/x86)
include_directories(${DDS_INSTALL_X86}/include)
link_directories(${DDS_INSTALCALMCARL_X86}/lib)
set(RCLCPP_INSTALL_X86 ${CALMCAR_MASTER_3RDPARTY_LIBS_DIR}/x86)
include_directories(${RCLCPP_INSTALL_X86}/include)
link_directories(${RCLCPP_INSTALL_X86}/lib)
set(BOOST_INSTALL_X86 ${CALMCAR_MASTER_3RDPARTY_LIBS_DIR}/x86)
include_directories(${BOOST_INSTALL_X86}/include)
link_directories(${BOOST_INSTALL_X86}/lib)
elseif(USE_CC_PEGASUS)
message(STATUS "================ -] building PEGASUS [- ================")
ADD_DEFINITIONS(-DUSE_CC_PEGASUS=1)
# set cross-compiled `protobuf3.6.1` header files
set(PROTOBUF3_INSTALL_ARM ${CALMCAR_MASTER_3RDPARTY_LIBS_DIR}/arm)
include_directories(${PROTOBUF3_INSTALL_ARM}/include)
link_directories(${PROTOBUF3_INSTALCALMCARL_ARM}/lib)
# set cross-compiled `DDS` header files
set(DDS_INSTALL_ARM ${CALMCAR_MASTER_3RDPARTY_LIBS_DIR}/arm)
include_directories(${DDS_INSTALL_ARM}/include)
link_directories(${DDS_INSTALCALMCARL_ARM}/lib)
set(RCLCPP_INSTALL_ARM ${CALMCAR_MASTER_3RDPARTY_LIBS_DIR}/arm)
include_directories(${RCLCPP_INSTALL_ARM}/include)
link_directories(${RCLCPP_INSTALL_ARM}/lib)
set(BOOST_INSTALL_ARM ${CALMCAR_MASTER_3RDPARTY_LIBS_DIR}/arm)
include_directories(${BOOST_INSTALL_ARM}/include)
link_directories(${BOOST_INSTALL_ARM}/lib)
endif()
# set install url
if(USE_CC_QNX)
message(STATUS "All binary files' OUTPUT DIRECTORY: ${CALMCAR_MASTER_ROOT}/bin_aarch64_qnx")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin_aarch64_qnx/SWCS)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin_aarch64_qnx/SWCS)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin_aarch64_qnx/SWCS)
elseif(USE_CC_PEGASUS)
message(STATUS "All binary files' OUTPUT DIRECTORY: ${CALMCAR_MASTER_ROOT}/bin_aarch64_pegasus")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin_aarch64_pegasus/SWCS)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin_aarch64_pegasus/SWCS)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin_aarch64_pegasus/SWCS)
elseif(USE_CC_X86)
message(STATUS "All binary files' OUTPUT DIRECTORY: ${CALMCAR_MASTER_ROOT}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin/SWCS)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin/SWCS)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin/SWCS)
else()
message(STATUS "All binary files' OUTPUT DIRECTORY: ${CALMCAR_MASTER_ROOT}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin/SWCS)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/02_bin/SWCS)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin/SWCS)
endif()
endif()
if(USE_CC_PEGASUS)
message(STATUS "All binary files' OUTPUT DIRECTORY: ${CALMCAR_MASTER_ROOT}/bin_aarch64_pegasus")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin_aarch64_pegasus/SWCS/canbuslibs)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin_aarch64_pegasus/SWCS/canbuslibs)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin_aarch64_pegasus/SWCS)
elseif(USE_CC_X86)
message(STATUS "All binary files' OUTPUT DIRECTORY: ${CALMCAR_MASTER_ROOT}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin/SWCS/canbuslibs)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin/SWCS/canbuslibs)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin/SWCS)
else()
message(STATUS "All binary files' OUTPUT DIRECTORY: ${CALMCAR_MASTER_ROOT}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin/SWCS/canbuslibs)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin/SWCS/canbuslibs)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CALMCAR_MASTER_ROOT}/01_bin/SWCS)
endif()
if(USE_CC_X86)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
message("x86")
set(CALMCAR_CANBUS_LIBS ${CALMCAR_MASTER_ROOT}/01_bin/SWCS)
link_directories(${CALMCAR_CANBUS_LIBS}/canbuslibs)
set(DDS_INSTALL_X86 ${CALMCAR_MASTER_3RDPARTY_LIBS_DIR}/x86)
include_directories(${DDS_INSTALL_X86}/include/dds)
include_directories(${DDS_INSTALL_X86}/include)
link_directories(${DDS_INSTALL_X86}/lib)
set(CALMCAR_MASTER_INTERFACES ${CALMCAR_MASTER_ROOT}/08_interfaces)
elseif(USE_CC_PEGASUS)
message(" ==== PEGASUS")
set(CALMCAR_CANBUS_LIBS ${CALMCAR_MASTER_ROOT}/01_bin_aarch64_pegasus/SWCS)
link_directories(${CALMCAR_CANBUS_LIBS}/canbuslibs)
set(DDS_INSTALL_ARM ${CALMCAR_MASTER_3RDPARTY_LIBS_DIR}/arm)
include_directories(${DDS_INSTALL_ARM}/include/dds)
link_directories(${DDS_INSTALL_ARM}/lib)
include_directories(${DDS_INSTALL_ARM}/include)
set(CALMCAR_MASTER_INTERFACES ${CALMCAR_MASTER_ROOT}/08_interfaces)
endif()
include_directories(${CALMCAR_MASTER_INTERFACES}/include)
include_directories(${CANBUS_MASTER_DIR})
include_directories(${CANBUS_MASTER_DIR}/DriverCanbus)
include_directories(${CANBUS_MASTER_DIR}/util/include)
include_directories(${CANBUS_MASTER_DIR}/util/)
# ======== Genarate libs =========
set(GENERATE_LIBS ON)
if(GENERATE_LIBS)
FILE(GLOB_RECURSE PROJECT_HEADERS "${CALMCAR_MASTER_INTERFACES}/include/*.h")
FILE(GLOB_RECURSE PROJECT_SOURCES "${CALMCAR_MASTER_INTERFACES}/include/*.cc")
# ADD_LIBRARY (canbusInterface_s SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
# ADD_LIBRARY (CanbusInterface_s STATIC ${PROJECT_SOURCES} ${PROJECT_HEADERS})
if(USE_CC_X86)
FILE(GLOB_RECURSE CanbusInterface_s "${CALMCAR_MASTER_INTERFACES}/lib/x86/*.a") # proto生成的静态库.a
elseif(USE_CC_PEGASUS)
FILE(GLOB_RECURSE CanbusInterface_s "${CALMCAR_MASTER_INTERFACES}/lib/arm/*.a") # proto生成的静态库.a
endif()
add_subdirectory(util)
add_subdi