Skip to content

Commit

Permalink
add option to change the default library name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sauci committed Aug 6, 2019
1 parent c6e0934 commit e6d0310
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ option(ENABLE_SCA "enable/disable static code analysis." OFF)
option(ENABLE_DOC "enable/disable documentation generation." OFF)
set(MISRA_C_VERSION 2012 CACHE STRING "MISRA standard.")
set(CANTP_CONFIG_FILEPATH ${CMAKE_CURRENT_SOURCE_DIR}/config/can_tp.json CACHE FILEPATH "")
set(OUTPUT_LIB_NAME CanTp CACHE STRING "default library name")

find_package(PythonInterp 3.6 REQUIRED)

Expand All @@ -25,9 +26,9 @@ endif ()

add_subdirectory(generated)

add_library(${PROJECT_NAME} STATIC source/CanTp.c)
add_library(${OUTPUT_LIB_NAME} STATIC source/CanTp.c)

target_compile_definitions(${PROJECT_NAME}
target_compile_definitions(${OUTPUT_LIB_NAME}
PRIVATE CANTP_DEV_ERROR_DETECT=$<IF:$<BOOL:${ENABLE_DET}>,STD_ON,STD_OFF>
PRIVATE CANTP_SW_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
PRIVATE CANTP_SW_VERSION_MINOR=${PROJECT_VERSION_MINOR}
Expand All @@ -44,15 +45,15 @@ target_compile_definitions(${PROJECT_NAME}
PUBLIC CANTP_READ_PARAMETER_API=STD_ON
PUBLIC CANTP_BUILD_CFFI_INTERFACE=$<IF:$<BOOL:${ENABLE_TEST}>,STD_ON,STD_OFF>)

target_include_directories(${PROJECT_NAME}
target_include_directories(${OUTPUT_LIB_NAME}
PUBLIC interface
PUBLIC $<$<BOOL:${ENABLE_TEST}>:${CMAKE_CURRENT_SOURCE_DIR}/generated>
PUBLIC $<$<BOOL:${ENABLE_TEST}>:${CMAKE_CURRENT_SOURCE_DIR}/test/stub>)

if (${ENABLE_TEST})
ENABLE_TESTing()

target_link_libraries(${PROJECT_NAME}
target_link_libraries(${OUTPUT_LIB_NAME}
PUBLIC CanTp_PBcfg)

add_test(NAME CanTp_UnitTest
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The following definitions might be set by the user, depending on the needs.
| ```ENABLE_SCA``` | ```ON```/```OFF``` | ```OFF``` | enables/disables generation of targets related to static code analysis (should be disabled if [lint](https://www.gimpel.com) software is not available) |
| ```MISRA_C_VERSION``` | ```1998```/```2004```/```2012``` | ```2012``` | specifies which version of **MISRA** should be used when performing static code analysis (only used if ```ENABLE_SCA``` is set) |
| ```CANTP_CONFIG_FILEPATH``` | ```-``` | ```CanTp/config/can_tp.json``` | specifies which json configuration file should be used to generate the auto-generated code |
| ```OUTPUT_LIB_NAME``` | ```-``` | ```CanTp``` | specifies the library's name |
| ```ENABLE_DOC``` | ```ON```/```OFF``` | ```OFF``` | enables/disables generation of [Doxygen](http://www.doxygen.nl/) documentation |

To use this feature, simply add ```-D<definition>=<value>``` when configuring the build with CMake.
4 changes: 2 additions & 2 deletions config/cffi_config.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import sys
build_directory = "${CMAKE_BINARY_DIR}"
header = "${PROJECT_SOURCE_DIR}/interface/CanTp.h"
source = "${PROJECT_SOURCE_DIR}/source/CanTp.c"
compile_definitions = "$<JOIN:$<TARGET_PROPERTY:${PROJECT_NAME},COMPILE_DEFINITIONS>,$<SEMICOLON>>".split(';')
include_directories = "$<JOIN:$<TARGET_PROPERTY:${PROJECT_NAME},INCLUDE_DIRECTORIES>,$<SEMICOLON>>".split(';')
compile_definitions = "$<JOIN:$<TARGET_PROPERTY:${OUTPUT_LIB_NAME},COMPILE_DEFINITIONS>,$<SEMICOLON>>".split(';')
include_directories = "$<JOIN:$<TARGET_PROPERTY:${OUTPUT_LIB_NAME},INCLUDE_DIRECTORIES>,$<SEMICOLON>>".split(';')

sys.path.append("${PROJECT_SOURCE_DIR}/script")
sys.path.append(build_directory)
Expand Down

0 comments on commit e6d0310

Please sign in to comment.