Skip to content

Commit

Permalink
[#2][WIP] PkgConfig include initools
Browse files Browse the repository at this point in the history
Signed-off-by: Clovis Durand <cd.clovel19@gmail.com>
  • Loading branch information
Clovel committed Mar 4, 2020
1 parent e166d30 commit 6f2ebc1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
38 changes: 22 additions & 16 deletions generator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_PROJECT_BRIEF "OSCO Object Disctionary generator")

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/dest CACHE PATH "" FORCE)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/dest CACHE PATH "" FORCE)
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

# Allow CTest
Expand All @@ -67,18 +67,21 @@ option(ENABLE_DOCS "Build API documentation" ${DOXYGEN_FOUND})
#------------------------------------------------------------------------------
# pkg-config dependencies
#------------------------------------------------------------------------------
find_package(PkgConfig REQUIRED)

set(ENV{PKG_CONFIG_PATH} "ENV{PKG_CONFIG_PATH}:${PKG_CONFIG_PATH}")
set(ENV{PKG_CONFIG_PATH} "ENV{PKG_CONFIG_PATH}:${PKG_CONFIG_PATH}:${CMAKE_CURRENT_SOURCE_DIR}/deps/initools")
message(STATUS "Pkgconfig extra path are: $ENV{PKG_CONFIG_PATH}")

pkg_check_modules(INITOOLS REQUIRED initools)

#------------------------------------------------------------------------------
# Project version
#------------------------------------------------------------------------------

# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
Expand Down Expand Up @@ -113,12 +116,12 @@ find_package(PkgConfig REQUIRED)
if(PKG_CONFIG_FOUND)
# Produce a pkg-config file
configure_file (
${CMAKE_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.pc.in
${CMAKE_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.pc
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.pc.in
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.pc
@ONLY
)
install (
FILES ${CMAKE_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.pc
FILES ${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.pc
DESTINATION lib/pkgconfig
)
endif(PKG_CONFIG_FOUND)
Expand All @@ -127,8 +130,11 @@ endif(PKG_CONFIG_FOUND)
# Project configuration
#------------------------------------------------------------------------------

include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/inc)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/inc
${INITOOLS_INCLUDE_DIRS}
)

#------------------------------------------------------------------------------
# Sub-directories
Expand Down Expand Up @@ -160,17 +166,17 @@ endif (ENABLE_DOCS)
#------------------------------------------------------------------------------

set(COVERITY_FILES
" ${CMAKE_SOURCE_DIR}/build-coverity/output/summary.txt"
" ${CMAKE_CURRENT_SOURCE_DIR}/build-coverity/output/summary.txt"
)

add_custom_command(OUTPUT ${COVERITY_FILES}
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} mkdir -p build-coverity
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} cov-configure --gcc
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} cov-build --dir build-coverity make -j $(nproc)
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} cov-analyze --dir build-coverity --all --aggressiveness-level low --misra-config MISRA_c2012_MM.config
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} cov-commit-defects --dir build-coverity --host coverity3.freescale.net --user committer --password CoverityGuest --stream lib${PROJECT_NAME}
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_SOURCE_DIR} mkdir -p build-coverity
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_SOURCE_DIR} cov-configure --gcc
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_SOURCE_DIR} cov-build --dir build-coverity make -j $(nproc)
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_SOURCE_DIR} cov-analyze --dir build-coverity --all --aggressiveness-level low --misra-config MISRA_c2012_MM.config
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_SOURCE_DIR} cov-commit-defects --dir build-coverity --host coverity3.freescale.net --user committer --password CoverityGuest --stream lib${PROJECT_NAME}
COMMAND ${CMAKE_COMMAND} -E touch ${COVERITY_FILES}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "run coverity"
)
add_custom_target(coverity DEPENDS ${COVERITY_FILES})
add_custom_target(${CMAKE_PROJECT_NAME}-coverity DEPENDS ${COVERITY_FILES})
2 changes: 1 addition & 1 deletion generator/docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if(DOXYGEN_FOUND)
message("Doxygen build started")

# note the option ALL which allows to build the docs together with the application
add_custom_target(doc_doxygen ALL
add_custom_target(${CMAKE_PROJECT_NAME}-doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs
COMMENT "Generating API documentation with Doxygen"
Expand Down
15 changes: 9 additions & 6 deletions generator/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

# Header files --------------------------------------------
file(GLOB PUBLIC_HEADERS
${CMAKE_SOURCE_DIR}/inc/*.h
${CMAKE_SOURCE_DIR}/inc/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/../inc/*.h
${CMAKE_CURRENT_SOURCE_DIR}/../inc/*.hpp
)

file(GLOB_RECURSE MODULE_HEADERS
${CMAKE_SOURCE_DIR}/src/*.h
${CMAKE_SOURCE_DIR}/src/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/*.h
${CMAKE_CURRENT_SOURCE_DIR}/*.hpp
)

set(HEADERS
Expand All @@ -21,8 +21,8 @@ set(HEADERS

# Source files --------------------------------------------
file(GLOB SOURCES
${CMAKE_SOURCE_DIR}/src/*.c
${CMAKE_SOURCE_DIR}/src/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/*.c
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
)

message("MAIN SOURCES : ${SOURCES}")
Expand All @@ -33,6 +33,9 @@ message("MAIN SOURCES : ${SOURCES}")
add_executable(${CMAKE_PROJECT_NAME}
${SOURCES}
)
target_link_libraries(${CMAKE_PROJECT_NAME}
${INITOOLS_LIBRARIES}
)
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
PUBLIC_HEADER "${PUBLIC_HEADERS}"
)
Expand Down
8 changes: 4 additions & 4 deletions generator/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ add_definitions(-DTEST)

# Header files --------------------------------------------
file(GLOB_RECURSE PUBLIC_HEADERS
${CMAKE_SOURCE_DIR}/inc/*.h
${CMAKE_SOURCE_DIR}/inc/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/../inc/*.h
${CMAKE_CURRENT_SOURCE_DIR}/../inc/*.hpp
)
set(HEADERS
${PUBLIC_HEADERS}
)

include_directories(
${CMAKE_SOURCE_DIR}/inc
${CMAKE_CURRENT_SOURCE_DIR}/../inc
)

# Source files --------------------------------------------
file(GLOB_RECURSE TEST_SOURCES
${CMAKE_SOURCE_DIR}/tests/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
)

# Target definition ---------------------------------------
Expand Down

0 comments on commit 6f2ebc1

Please sign in to comment.