new cmake
This commit is contained in:
143
CMakeLists.txt
143
CMakeLists.txt
@@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.0)
|
||||
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||
project(pip)
|
||||
set(_PIP_MAJOR 1)
|
||||
set(_PIP_MINOR 23)
|
||||
set(_PIP_MINOR 24)
|
||||
set(_PIP_REVISION 0)
|
||||
set(_PIP_SUFFIX )
|
||||
set(_PIP_COMPANY SHS)
|
||||
set(_PIP_DOMAIN org.SHS)
|
||||
set(TESTS=true)
|
||||
|
||||
if ("x${CMAKE_MODULE_PATH}" STREQUAL "x")
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
endif()
|
||||
@@ -77,7 +77,7 @@ set(PIP_SRC_DIRS ${PIP_SRC_MAIN}
|
||||
${PIP_SRC_IO_UTILS}
|
||||
${PIP_SRC_CONCURRENT}
|
||||
${PIP_SRC_CLOUD}
|
||||
)
|
||||
)
|
||||
set(PIP_LIBS_TARGETS pip)
|
||||
set(LIBS_MAIN)
|
||||
set(LIBS_STATUS)
|
||||
@@ -85,8 +85,10 @@ set(HDRS)
|
||||
set(PHDRS)
|
||||
|
||||
if (TESTS)
|
||||
set(PIP_SRC_CONCURRENT_TEST "lib/concurrent/test")
|
||||
include(DownloadGTest)
|
||||
set(PIP_CONCURRENT_TEST "lib/concurrent/test")
|
||||
set(PIP_SRC_MATH_TEST "lib/main/math/test")
|
||||
set(PIP_SRC_CORE_TEST "lib/main/core/test")
|
||||
endif()
|
||||
|
||||
if (DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
|
||||
@@ -211,7 +213,7 @@ gather_src("${PIP_SRC_IO_UTILS}" CPP_LIB_IO_UTILS HDRS PHDRS)
|
||||
# Concurrent lib
|
||||
gather_src("${PIP_SRC_CONCURRENT}" CPP_LIB_CONCURRENT HDRS PHDRS)
|
||||
|
||||
gather_src("${PIP_SRC_CONCURRENT_TEST}" CPP_CONCURRENT_TEST HDRS PHDRS)
|
||||
gather_src("${PIP_CONCURRENT_TEST}" CPP_CONCURRENT_TEST HDRS PHDRS)
|
||||
|
||||
# Cloud lib
|
||||
gather_src("${PIP_SRC_CLOUD}" CPP_LIB_CLOUD HDRS PHDRS)
|
||||
@@ -219,6 +221,9 @@ gather_src("${PIP_SRC_CLOUD}" CPP_LIB_CLOUD HDRS PHDRS)
|
||||
#Math test lib
|
||||
gather_src("${PIP_SRC_MATH_TEST}" CPP_MATH_TEST HDRS PHDRS)
|
||||
|
||||
#Core test lib
|
||||
gather_src("${PIP_SRC_CORE_TEST}" CPP_CORE_TEST HDRS PHDRS)
|
||||
|
||||
if(PIP_FREERTOS)
|
||||
add_definitions(-DPIP_FREERTOS)
|
||||
set(ICU OFF)
|
||||
@@ -276,16 +281,6 @@ else()
|
||||
message(STATUS "Building PIP release version")
|
||||
endif()
|
||||
|
||||
if (TESTS)
|
||||
include(DownloadGTest)
|
||||
set(CONCURRENT_TESTS 1) #"Enable tests for concurrent library"
|
||||
set(MATH_TESTS 1) #"Enable tests for concurrent library"
|
||||
else()
|
||||
set(CONCURRENT_TESTS 0)
|
||||
set(MATH_TESTS 0)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
# Check if std::iostream operators support
|
||||
if(STD_IOSTREAM)
|
||||
@@ -323,37 +318,37 @@ if ((NOT DEFINED _PIP_SAVED_DEFS) OR (NOT "x${_PIP_SAVED_DEFS}" STREQUAL "x${_PI
|
||||
if (NOT "x${_PIP_DEFS}" STREQUAL "x")
|
||||
file(APPEND ${_PIP_DEFS_FILE} "#ifndef ${_PIP_DEFS}\n# define ${_PIP_DEFS}\n#endif\n")
|
||||
endif()
|
||||
endif()
|
||||
list(APPEND HDRS ${_PIP_DEFS_FILE})
|
||||
#message("${_PIP_DEFS_CHANGED}")
|
||||
endif()
|
||||
list(APPEND HDRS ${_PIP_DEFS_FILE})
|
||||
#message("${_PIP_DEFS_CHANGED}")
|
||||
|
||||
|
||||
# Check if RT timers exists
|
||||
if(PIP_TIMER_RT_0 AND PIP_TIMER_RT_1 AND PIP_TIMER_RT_2)
|
||||
# Check if RT timers exists
|
||||
if(PIP_TIMER_RT_0 AND PIP_TIMER_RT_1 AND PIP_TIMER_RT_2)
|
||||
add_definitions(-DPIP_TIMER_RT)
|
||||
message(STATUS "Building PIP with timers: Thread, ThreadRT, Pool")
|
||||
else()
|
||||
else()
|
||||
message(STATUS "Building PIP with timers: Thread, Pool")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
# Add main library
|
||||
if(APPLE)
|
||||
# Add main library
|
||||
if(APPLE)
|
||||
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
|
||||
endif()
|
||||
if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM))
|
||||
endif()
|
||||
if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM))
|
||||
include_directories(${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include)
|
||||
#message("${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include")
|
||||
#message("${ANDROID_NDK}/sysroot/usr/include")
|
||||
endif()
|
||||
if(NOT PIP_FREERTOS)
|
||||
if(WIN32)
|
||||
endif()
|
||||
if(NOT PIP_FREERTOS)
|
||||
if(WIN32)
|
||||
if(${C_COMPILER} STREQUAL "cl.exe")
|
||||
else()
|
||||
list(APPEND LIBS_MAIN ws2_32 iphlpapi psapi cfgmgr32 setupapi)
|
||||
endif()
|
||||
else()
|
||||
else()
|
||||
list(APPEND LIBS_MAIN dl)
|
||||
if(DEFINED ENV{QNX_HOST})
|
||||
list(APPEND LIBS_MAIN socket)
|
||||
@@ -362,12 +357,12 @@ else()
|
||||
list(APPEND LIBS_MAIN pthread util)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
set(PIP_LIBS)
|
||||
if(PIP_FREERTOS)
|
||||
endif()
|
||||
endif()
|
||||
set(PIP_LIBS)
|
||||
if(PIP_FREERTOS)
|
||||
set(PIP_LIBS ${LIBS_MAIN})
|
||||
else()
|
||||
else()
|
||||
foreach(LIB_ ${LIBS_MAIN})
|
||||
find_library(${LIB_}_FOUND ${LIB_})
|
||||
if(${LIB_}_FOUND)
|
||||
@@ -375,31 +370,31 @@ else()
|
||||
list(APPEND PIP_LIBS ${${LIB_}_FOUND})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
list(APPEND LIBS_STATUS ${LIBS_MAIN})
|
||||
import_version(pip PIP)
|
||||
if(WIN32)
|
||||
endif()
|
||||
list(APPEND LIBS_STATUS ${LIBS_MAIN})
|
||||
import_version(pip PIP)
|
||||
if(WIN32)
|
||||
make_rc(pip _RC)
|
||||
add_definitions(-DPSAPI_VERSION=1)
|
||||
add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN} ${HDRS} ${PHDRS} ${_RC})
|
||||
if(${C_COMPILER} STREQUAL "cl.exe")
|
||||
set(CMAKE_CXX_FLAGS "/O2 /Ob2 /Ot /W0")
|
||||
endif()
|
||||
else()
|
||||
else()
|
||||
set(${CMAKE_CXX_FLAGS} "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
if(DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32")
|
||||
else()
|
||||
endif()
|
||||
add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN})
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
include(GenerateExportHeader)
|
||||
generate_export_header(pip)
|
||||
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h")
|
||||
target_link_libraries(pip ${PIP_LIBS})
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
include(GenerateExportHeader)
|
||||
generate_export_header(pip)
|
||||
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h")
|
||||
target_link_libraries(pip ${PIP_LIBS})
|
||||
|
||||
if (NOT CROSSTOOLS)
|
||||
if (NOT CROSSTOOLS)
|
||||
if (NOT PIP_FREERTOS)
|
||||
# Check if USB is supported
|
||||
find_library(usb_FOUND usb SHARED)
|
||||
@@ -603,19 +598,27 @@ if (NOT CROSSTOOLS)
|
||||
list(APPEND PIP_LIBS_TARGETS pip_concurrent)
|
||||
|
||||
# Enable build tests for concurrent module
|
||||
if(CONCURRENT_TESTS)
|
||||
if(PIP_CONCURRENT_TEST)
|
||||
add_executable(pip_concurrent_test ${CPP_CONCURRENT_TEST})
|
||||
target_link_libraries(pip_concurrent_test gtest_main gmock_main pip_concurrent)
|
||||
add_test(NAME pip_concurrent_test COMMAND tests)
|
||||
add_custom_target(pip_concurrent_test_perform ALL COMMAND pip_concurrent_test)
|
||||
endif()
|
||||
if(MATH_TESTS)
|
||||
|
||||
if(PIP_SRC_MATH_TEST)
|
||||
add_executable(pip_math_test ${CPP_MATH_TEST})
|
||||
target_link_libraries(pip_math_test gtest_main gmock_main PIP)
|
||||
add_test(NAME pip_math_test COMMAND tests)
|
||||
#add_custom_target(pip_math_test_perform ALL COMMAND pip_math_test)
|
||||
endif()
|
||||
|
||||
if(PIP_SRC_CORE_TEST)
|
||||
add_executable(pip_core_test ${CPP_CORE_TEST})
|
||||
target_link_libraries(pip_core_test gtest_main gmock_main PIP)
|
||||
add_test(NAME pip_core_test COMMAND tests)
|
||||
#add_custom_target(pip_core_test_perform ALL COMMAND pip_core_test)
|
||||
endif()
|
||||
|
||||
# Build cloud library if crypt enabled
|
||||
if(sodium_FOUND)
|
||||
message(STATUS "Building PICloud support")
|
||||
@@ -659,11 +662,11 @@ if (NOT CROSSTOOLS)
|
||||
list(APPEND PIP_LIBS_TARGETS pip_compress)
|
||||
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Install
|
||||
# Check if system or local install will be used (to system install use "-DLIB=" argument of cmake)
|
||||
if(LIB)
|
||||
# Install
|
||||
# Check if system or local install will be used (to system install use "-DLIB=" argument of cmake)
|
||||
if(LIB)
|
||||
if(WIN32)
|
||||
if(MINGW)
|
||||
if (NOT CROSSTOOLS)
|
||||
@@ -692,7 +695,7 @@ if(LIB)
|
||||
message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
|
||||
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore")
|
||||
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
|
||||
else()
|
||||
else()
|
||||
if(NOT PIP_FREERTOS)
|
||||
if(WIN32)
|
||||
install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION bin)
|
||||
@@ -703,16 +706,16 @@ else()
|
||||
install(FILES ${HDRS} DESTINATION include/pip)
|
||||
message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT PIP_FREERTOS)
|
||||
if(NOT PIP_FREERTOS)
|
||||
|
||||
# Auxiliary
|
||||
# Auxiliary
|
||||
if (NOT CROSSTOOLS)
|
||||
add_subdirectory("${PIP_SRC_MAIN}/auxiliary/piterminal")
|
||||
endif()
|
||||
|
||||
# Utils
|
||||
# Utils
|
||||
add_subdirectory("utils/code_model_generator")
|
||||
add_subdirectory("utils/resources_compiler")
|
||||
add_subdirectory("utils/deploy_tool")
|
||||
@@ -727,29 +730,29 @@ if(NOT PIP_FREERTOS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# Libraries messages
|
||||
message(STATUS "Building PIP modules: ${PIP_LIBS_TARGETS}")
|
||||
if(DEFINED LIBPROJECT)
|
||||
# Libraries messages
|
||||
message(STATUS "Building PIP modules: ${PIP_LIBS_TARGETS}")
|
||||
if(DEFINED LIBPROJECT)
|
||||
set(PIP_LIBS_TARGETS ${PIP_LIBS_TARGETS} PARENT_SCOPE)
|
||||
list(APPEND _ALL_TARGETS ${PIP_LIBS_TARGETS})
|
||||
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
|
||||
endif()
|
||||
if(NOT PIP_FREERTOS)
|
||||
endif()
|
||||
if(NOT PIP_FREERTOS)
|
||||
foreach(LIB_ ${LIBS_STATUS})
|
||||
message(STATUS "Library ${LIB_} -> " ${${LIB_}_FOUND})
|
||||
if(NOT ${LIB_}_FOUND)
|
||||
message(WARNING "Library ${LIB_} not found, please install it")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# Build Documentation
|
||||
#
|
||||
if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
|
||||
#
|
||||
# Build Documentation
|
||||
#
|
||||
if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
|
||||
include(PIPDocumentation)
|
||||
find_package(Doxygen)
|
||||
if(DOXYGEN_FOUND)
|
||||
@@ -773,5 +776,5 @@ if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
|
||||
add_documentation(doc doc/Doxyfile.in)
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION ../share/doc/pip COMPONENT doc EXCLUDE_FROM_ALL OPTIONAL)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user