Skip to content
Snippets Groups Projects
Commit e9fd5e05 authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

Merge pull request #6 in HIDRA2/hidra2 from feature/HIDRA2-24-call-astyle-automatically to develop

* commit 'ef5e16f9':
  run astyle over all sources when executing make
parents 306580ff ef5e16f9
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ option(BUILD_DOCS "Uses doxygen to build the documentaion" OFF)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules/)
# format sources
include(astyle)
include(testing_cpp)
......
function(astyle target source_files)
find_program(ASTYLE_EXECUTABLE astyle)
if(ASTYLE_EXECUTABLE)
message(STATUS "Found astyle, using astyle to format code of target ${target}.")
add_custom_command(
TARGET ${target} PRE_BUILD
COMMAND
${ASTYLE_EXECUTABLE} -n --style=1tbs --indent-namespaces --indent-preproc-block ${source_files}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} VERBATIM
find_program(ASTYLE_EXECUTABLE astyle)
add_custom_target(ASTYLE)
if(ASTYLE_EXECUTABLE)
message(STATUS "Found astyle, using astyle to format code of target ${target}.")
add_custom_target(astyle ALL
COMMAND
${ASTYLE_EXECUTABLE} -i
--exclude=${PROJECT_BINARY_DIR}
--recursive -n --style=google
"${PROJECT_SOURCE_DIR}/*.cpp" "${PROJECT_SOURCE_DIR}/*.h"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
VERBATIM
)
else()
message(WARNING "Unable to find astyle. Skipping code formatting for ${target}")
endif()
endfunction()
else()
message(WARNING "Unable to find astyle. Code formatting willbe skipped")
endif()
......@@ -12,8 +12,6 @@ function(gtest target test_source_files test_libraries)
target_link_libraries(test-${target} ${test_libraries})
add_test(NAME test-${target} COMMAND test-${target})
astyle(test-${target} ${test_source_files})
message(STATUS "Added test 'test-${target}'")
if(CMAKE_COMPILER_IS_GNUCXX)
......
......@@ -9,9 +9,6 @@ add_library(${TARGET_NAME} SHARED ${SOURCE_FILES})
target_include_directories(${TARGET_NAME} PUBLIC include)
set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX)
astyle(${TARGET_NAME} ${SOURCE_FILES})
################################
# Testing
################################
......
......@@ -10,9 +10,6 @@ target_include_directories(${TARGET_NAME} PUBLIC include)
target_link_libraries(${TARGET_NAME} common)
set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX)
astyle(${TARGET_NAME} ${SOURCE_FILES})
################################
# Testing
################################
......
......@@ -10,9 +10,6 @@ target_include_directories(${TARGET_NAME} PRIVATE include)
target_link_libraries(${TARGET_NAME} common producer-api)
set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX)
astyle(${TARGET_NAME} ${SOURCE_FILES})
################################
# Testing
################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment