# HG changeset patch # User David Demelier # Date 1539973622 -7200 # Node ID 387f6b0a5420c25ef9ae67df7568cebd9249b95f # Parent 3107ce017c3a1b93b50627b97948a5a41ba54ec1 CMake: remove vera until we get clang-tidy, #903 diff -r 3107ce017c3a -r 387f6b0a5420 CMakeLists.txt --- a/CMakeLists.txt Fri Oct 19 20:18:19 2018 +0200 +++ b/CMakeLists.txt Fri Oct 19 20:27:02 2018 +0200 @@ -30,7 +30,6 @@ include(cmake/function/MalikaniaDefineExecutable.cmake) include(cmake/function/MalikaniaDefineTest.cmake) include(cmake/function/MalikaniaSetg.cmake) -include(cmake/function/MalikaniaVeraCheck.cmake) include(cmake/MalikaniaVersion.cmake) include(cmake/MalikaniaOptions.cmake) @@ -73,5 +72,4 @@ message(" Doxygen: ${WITH_DOXYGEN_MSG}") message("") message("Additional options:") -message(" Vera: ${WITH_VERA_MSG}") message(" Tests: ${WITH_TESTS_MSG}") diff -r 3107ce017c3a -r 387f6b0a5420 cmake/MalikaniaOptions.cmake --- a/cmake/MalikaniaOptions.cmake Fri Oct 19 20:18:19 2018 +0200 +++ b/cmake/MalikaniaOptions.cmake Fri Oct 19 20:27:02 2018 +0200 @@ -21,37 +21,37 @@ # ------------------------------------------------------------------- # # The following options are available: -# WITH_BACKEND - Type of backend to use. (Default: SDL) +# WITH_BACKEND - Type of backend to use. (Default: SDL) # set(WITH_BACKEND "SDL" - CACHE STRING "Which backend to use") + CACHE STRING "Which backend to use") # # Documentation and technical references # ------------------------------------------------------------------- # # The following options are available: -# WITH_DOCS - Disable or enable all docs, if set to Off, disable all documentation. -# WITH_DOXYGEN - Enable doxygen +# WITH_DOCS - Disable or enable all docs, if set to Off, disable all documentation. +# WITH_DOXYGEN - Enable doxygen # option(WITH_DOCS "Build all documentation" On) option(WITH_DOXYGEN "Enable doxygen generation" On) if (NOT WITH_DOCS) - set(WITH_DOXYGEN Off) + set(WITH_DOXYGEN Off) endif () set(WITH_DRIVERDIR "lib/malikania/${MALIKANIA_VERSION}" - CACHE STRING "Database driver directory") + CACHE STRING "Database driver directory") set(WITH_BINDIR "libexec/malikania/${MALIKANIA_VERSION}" - CACHE STRING "Front end directory") + CACHE STRING "Front end directory") if (IS_ABSOLUTE ${WITH_DRIVERDIR}) - message(FATAL_ERROR "WITH_DRIVERDIR must not be absolute") + message(FATAL_ERROR "WITH_DRIVERDIR must not be absolute") elseif (IS_ABSOLUTE ${WITH_BINDIR}) - message(FATAL_ERROR "WITH_BINDIR must not be absolute") + message(FATAL_ERROR "WITH_BINDIR must not be absolute") endif () # @@ -59,44 +59,19 @@ # ------------------------------------------------------------------- # -option(WITH_VERA "Enable vera++ analyzer" On) option(WITH_TESTS "Enable unit tests" On) option(WITH_EXAMPLES "Enable examples" On) -find_program(VERA_EXECUTABLE vera++) - -if (VERA_EXECUTABLE) - if (WITH_VERA) - execute_process( - COMMAND ${VERA_EXECUTABLE} --version - OUTPUT_VARIABLE VERA_VERSION - ) - - if (${VERA_VERSION} VERSION_LESS "1.3.0") - malikania_setg(WITH_VERA Off) - malikania_setg(WITH_VERA_MSG "No (1.3.0 or greater required)") - else () - malikania_setg(WITH_VERA_MSG "Yes") - endif () - else () - malikania_setg(WITH_VERA Off) - malikania_setg(WITH_VERA_MSG "No (disabled by user)") - endif () +if (NOT WITH_TESTS) + malikania_setg(WITH_TESTS_MSG "No (disabled by user)") else () - malikania_setg(WITH_VERA Off) - malikania_setg(WITH_VERA_MSG "No (vera++ not found)") -endif () - -if (NOT WITH_TESTS) - malikania_setg(WITH_TESTS_MSG "No (disabled by user)") -else () - malikania_setg(WITH_TESTS_MSG "Yes") + malikania_setg(WITH_TESTS_MSG "Yes") endif () if (NOT WITH_EXAMPLES) - malikania_setg(WITH_EXAMPLES_MSG "No (disabled by user)") + malikania_setg(WITH_EXAMPLES_MSG "No (disabled by user)") else () - malikania_setg(WITH_EXAMPLES_MSG "Yes") + malikania_setg(WITH_EXAMPLES_MSG "Yes") endif () # @@ -105,33 +80,33 @@ # set(WITH_TEST_PGSQL_HOST "localhost" - CACHE STRING "Hostname for PostgreSQL driver") + CACHE STRING "Hostname for PostgreSQL driver") set(WITH_TEST_PGSQL_PORT "5432" - CACHE STRING "Port for PostgreSQL driver") + CACHE STRING "Port for PostgreSQL driver") set(WITH_TEST_PGSQL_DATABASE "malikaniadb" - CACHE STRING "Database for PostgreSQL driver") + CACHE STRING "Database for PostgreSQL driver") set(WITH_TEST_PGSQL_USER "malikania" - CACHE STRING "Username for PostgreSQL driver") + CACHE STRING "Username for PostgreSQL driver") # # Targets to build # ------------------------------------------------------------------- # # The following options are available: -# WITH_LIBCLIENT - Build the client library. -# WITH_LIBSERVER - Build the server library. +# WITH_LIBCLIENT - Build the client library. +# WITH_LIBSERVER - Build the server library. # option(WITH_LIBCLIENT "Build libclient" On) option(WITH_LIBSERVER "Build libserver" On) if (WITH_BACKEND MATCHES "SDL") - set(WITH_BACKEND_DIR "backend/sdl") + set(WITH_BACKEND_DIR "backend/sdl") else () - message(FATAL_ERROR "Unknown backend selected: ${WITH_BACKEND}") + message(FATAL_ERROR "Unknown backend selected: ${WITH_BACKEND}") endif () configure_file( - ${malikania_SOURCE_DIR}/cmake/internal/sysconfig-tests.h - ${malikania_BINARY_DIR}/sysconfig-tests.h + ${malikania_SOURCE_DIR}/cmake/internal/sysconfig-tests.h + ${malikania_BINARY_DIR}/sysconfig-tests.h ) diff -r 3107ce017c3a -r 387f6b0a5420 cmake/function/MalikaniaBuildAssets.cmake --- a/cmake/function/MalikaniaBuildAssets.cmake Fri Oct 19 20:18:19 2018 +0200 +++ b/cmake/function/MalikaniaBuildAssets.cmake Fri Oct 19 20:27:02 2018 +0200 @@ -44,18 +44,18 @@ # macro(malikania_build_assets inputs outputs) - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/assets) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/assets) - foreach (in ${inputs}) - get_filename_component(basename ${in} NAME_WE) - set(out ${CMAKE_CURRENT_BINARY_DIR}/assets/${basename}.hpp) - add_custom_command( - OUTPUT ${out} - COMMENT "Generating binary data from ${in}" - DEPENDS ${in} - COMMAND - $ ${basename} ${in} ${out} - ) - list(APPEND ${outputs} ${out}) - endforeach () + foreach (in ${inputs}) + get_filename_component(basename ${in} NAME_WE) + set(out ${CMAKE_CURRENT_BINARY_DIR}/assets/${basename}.hpp) + add_custom_command( + OUTPUT ${out} + COMMENT "Generating binary data from ${in}" + DEPENDS ${in} + COMMAND + $ ${basename} ${in} ${out} + ) + list(APPEND ${outputs} ${out}) + endforeach () endmacro() diff -r 3107ce017c3a -r 387f6b0a5420 cmake/function/MalikaniaDefineDatabase.cmake --- a/cmake/function/MalikaniaDefineDatabase.cmake Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -# -# MalikaniaDefineDatabase.cmake -- CMake build system for malikania -# -# Copyright (c) 2013-2018 David Demelier -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -# -# malikania_define_database -# ------------------------ -# -# malikania_define_database( -# NAME The target name -# SOURCES The sources -# FLAGS (Optional) List of flags -# INCLUDES (Optional) List of includes only for building the library -# LIBRARIES (Optional) List of libraries to link against -# ) -# -# Create a shared library that is dynamically loadable. -# - -include(CMakeParseArguments) - -include(${CMAKE_CURRENT_LIST_DIR}/MalikaniaVeraCheck.cmake) - -function(malikania_define_database) - set(singleArgs NAME) - set(multiArgs SOURCES FLAGS INCLUDES LIBRARIES) - - cmake_parse_arguments(DB "" "${singleArgs}" "${multiArgs}" ${ARGN}) - - if (NOT DB_NAME) - message(FATAL_ERROR "Missing NAME parameter") - endif () - if (NOT DB_SOURCES) - message(FATAL_ERROR "Missing SOURCES parameter") - endif () - - add_library(db-${DB_NAME} MODULE ${DB_SOURCES}) - target_link_libraries( - db-${DB_NAME} - libmlk-server - ${DB_LIBRARIES} - ) - target_include_directories( - db-${DB_NAME} - PRIVATE - ${DB_INCLUDES} - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} - ) - target_compile_definitions(db-${DB_NAME} PRIVATE ${DB_FLAGS}) - set_target_properties( - db-${DB_NAME} - PROPERTIES - OUTPUT_NAME ${DB_NAME} - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - PREFIX "" - ) - foreach (c ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${c} config) - set_target_properties( - db-${DB_NAME} - PROPERTIES - OUTPUT_NAME_${c} ${DB_NAME} - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${c} - ) - endforeach () - - malikania_vera_check(${DB_NAME} "${DB_SOURCES}") -endfunction() diff -r 3107ce017c3a -r 387f6b0a5420 cmake/function/MalikaniaDefineExample.cmake --- a/cmake/function/MalikaniaDefineExample.cmake Fri Oct 19 20:18:19 2018 +0200 +++ b/cmake/function/MalikaniaDefineExample.cmake Fri Oct 19 20:27:02 2018 +0200 @@ -18,40 +18,38 @@ include(CMakeParseArguments) -include(${CMAKE_CURRENT_LIST_DIR}/MalikaniaVeraCheck.cmake) +function(malikania_define_example) + set(singleArgs TARGET) + set(multiArgs FLAGS LIBRARIES SOURCES) -function(malikania_define_example) - set(singleArgs TARGET) - set(multiArgs FLAGS LIBRARIES SOURCES) + cmake_parse_arguments(EXP "" "${singleArgs}" "${multiArgs}" ${ARGN}) - cmake_parse_arguments(EXP "" "${singleArgs}" "${multiArgs}" ${ARGN}) - - if (NOT EXP_TARGET) - message(FATAL_ERROR "Missing TARGET parameter") - elseif (NOT EXP_SOURCES) - message(FATAL_ERROR "Missing SOURCES parameter") - endif () + if (NOT EXP_TARGET) + message(FATAL_ERROR "Missing TARGET parameter") + elseif (NOT EXP_SOURCES) + message(FATAL_ERROR "Missing SOURCES parameter") + endif () - add_executable(example-${EXP_TARGET} ${EXP_SOURCES}) - target_link_libraries(example-${EXP_TARGET} ${EXP_LIBRARIES}) - target_compile_definitions( - example-${EXP_TARGET} - PRIVATE - CMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" - CMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}" - ${EXP_FLAGS} - ) - set_target_properties( - example-${EXP_TARGET} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - ) - foreach (c ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${c} cu) - set_target_properties( - example-${EXP_TARGET} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY_${cu} ${CMAKE_BINARY_DIR}/bin/${c} - ) - endforeach () + add_executable(example-${EXP_TARGET} ${EXP_SOURCES}) + target_link_libraries(example-${EXP_TARGET} ${EXP_LIBRARIES}) + target_compile_definitions( + example-${EXP_TARGET} + PRIVATE + CMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" + CMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}" + ${EXP_FLAGS} + ) + set_target_properties( + example-${EXP_TARGET} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + ) + foreach (c ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${c} cu) + set_target_properties( + example-${EXP_TARGET} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY_${cu} ${CMAKE_BINARY_DIR}/bin/${c} + ) + endforeach () endfunction() diff -r 3107ce017c3a -r 387f6b0a5420 cmake/function/MalikaniaDefineExecutable.cmake --- a/cmake/function/MalikaniaDefineExecutable.cmake Fri Oct 19 20:18:19 2018 +0200 +++ b/cmake/function/MalikaniaDefineExecutable.cmake Fri Oct 19 20:27:02 2018 +0200 @@ -21,11 +21,11 @@ # --------------------------- # # malikania_define_executable( -# TARGET The target name -# SOURCES The list of sources -# FLAGS (Optional) List of flags -# INCLUDES (Optional) List of include directories -# LIBRARIES (Optional) List of libraries +# TARGET The target name +# SOURCES The list of sources +# FLAGS (Optional) List of flags +# INCLUDES (Optional) List of include directories +# LIBRARIES (Optional) List of libraries # ) # # Create an executable. Be sure to quote SOURCES, if not only the first file will be passed. @@ -35,45 +35,42 @@ include(CMakeParseArguments) include(${CMAKE_CURRENT_LIST_DIR}/MalikaniaBuildAssets.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/MalikaniaVeraCheck.cmake) function(malikania_define_executable) - set(singleArgs TARGET) - set(multiArgs ASSETS SOURCES FLAGS INCLUDES LIBRARIES) + set(singleArgs TARGET) + set(multiArgs ASSETS SOURCES FLAGS INCLUDES LIBRARIES) - cmake_parse_arguments(EXE "" "${singleArgs}" "${multiArgs}" ${ARGN}) + cmake_parse_arguments(EXE "" "${singleArgs}" "${multiArgs}" ${ARGN}) - if (NOT EXE_TARGET) - message(FATAL_ERROR "Missing TARGET parameter") - endif () - if (NOT EXE_SOURCES) - message(FATAL_ERROR "Missing SOURCES parameter") - endif () + if (NOT EXE_TARGET) + message(FATAL_ERROR "Missing TARGET parameter") + endif () + if (NOT EXE_SOURCES) + message(FATAL_ERROR "Missing SOURCES parameter") + endif () - malikania_build_assets("${EXE_ASSETS}" assets) + malikania_build_assets("${EXE_ASSETS}" assets) - add_executable(${EXE_TARGET} ${EXE_SOURCES} ${EXE_ASSETS} ${assets}) - target_link_libraries(${EXE_TARGET} ${EXE_LIBRARIES}) - target_include_directories( - ${EXE_TARGET} - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/assets - ${EXE_INCLUDES} - ) - target_compile_definitions(${EXE_TARGET} PRIVATE ${EXE_FLAGS}) - set_target_properties( - ${EXE_TARGET} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - ) - foreach (c ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${c} cu) - set_target_properties( - ${EXE_TARGET} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY_${cu} ${CMAKE_BINARY_DIR}/bin/${c} - ) - endforeach() - - malikania_vera_check(${EXE_TARGET} "${EXE_SOURCES}") + add_executable(${EXE_TARGET} ${EXE_SOURCES} ${EXE_ASSETS} ${assets}) + target_link_libraries(${EXE_TARGET} ${EXE_LIBRARIES}) + target_include_directories( + ${EXE_TARGET} + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/assets + ${EXE_INCLUDES} + ) + target_compile_definitions(${EXE_TARGET} PRIVATE ${EXE_FLAGS}) + set_target_properties( + ${EXE_TARGET} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + ) + foreach (c ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${c} cu) + set_target_properties( + ${EXE_TARGET} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY_${cu} ${CMAKE_BINARY_DIR}/bin/${c} + ) + endforeach() endfunction() diff -r 3107ce017c3a -r 387f6b0a5420 cmake/function/MalikaniaDefineLibrary.cmake --- a/cmake/function/MalikaniaDefineLibrary.cmake Fri Oct 19 20:18:19 2018 +0200 +++ b/cmake/function/MalikaniaDefineLibrary.cmake Fri Oct 19 20:27:02 2018 +0200 @@ -21,13 +21,13 @@ # ------------------------ # # malikania_define_library( -# TARGET The target name -# SOURCES The sources -# ASSETS (Optional) Additional assets files -# FLAGS (Optional) List of flags -# PRIVATE_INCLUDES (Optional) List of includes only for building the library -# PUBLIC_INCLUDES (Optional) List of public includes to share with the library users -# LIBRARIES (Optional) List of libraries to link against +# TARGET The target name +# SOURCES The sources +# ASSETS (Optional) Additional assets files +# FLAGS (Optional) List of flags +# PRIVATE_INCLUDES (Optional) List of includes only for building the library +# PUBLIC_INCLUDES (Optional) List of public includes to share with the library users +# LIBRARIES (Optional) List of libraries to link against # ) # # Create a shared library. Follow the same specification as malikania_define_executable. @@ -37,62 +37,59 @@ include(CMakeParseArguments) include(${CMAKE_CURRENT_LIST_DIR}/MalikaniaBuildAssets.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/MalikaniaVeraCheck.cmake) function(malikania_define_library) - set(singleArgs TARGET) - set(multiArgs ASSETS SOURCES FLAGS PRIVATE_INCLUDES PUBLIC_INCLUDES LIBRARIES) - set(mandatory TARGET SOURCES) + set(singleArgs TARGET) + set(multiArgs ASSETS SOURCES FLAGS PRIVATE_INCLUDES PUBLIC_INCLUDES LIBRARIES) + set(mandatory TARGET SOURCES) - cmake_parse_arguments(LIB "" "${singleArgs}" "${multiArgs}" ${ARGN}) + cmake_parse_arguments(LIB "" "${singleArgs}" "${multiArgs}" ${ARGN}) - if (NOT LIB_TARGET) - message(FATAL_ERROR "Missing TARGET parameter") - endif () - if (NOT LIB_SOURCES) - message(FATAL_ERROR "Missing SOURCES parameter") - endif () + if (NOT LIB_TARGET) + message(FATAL_ERROR "Missing TARGET parameter") + endif () + if (NOT LIB_SOURCES) + message(FATAL_ERROR "Missing SOURCES parameter") + endif () - # Enable assets for libraries. - malikania_build_assets("${LIB_ASSETS}" assets) + # Enable assets for libraries. + malikania_build_assets("${LIB_ASSETS}" assets) - # Create the shared library. - add_library(${LIB_TARGET} SHARED ${LIB_SOURCES} ${assets} ${LIB_ASSETS}) - target_link_libraries(${LIB_TARGET} ${LIB_LIBRARIES}) - target_include_directories( - ${LIB_TARGET} - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/assets - ${LIB_PRIVATE_INCLUDES} - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} - ${LIB_PUBLIC_INCLUDES} - ) - target_compile_definitions( - ${LIB_TARGET} - PRIVATE ${LIB_FLAGS} - CMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}" - CMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" - ) + # Create the shared library. + add_library(${LIB_TARGET} SHARED ${LIB_SOURCES} ${assets} ${LIB_ASSETS}) + target_link_libraries(${LIB_TARGET} ${LIB_LIBRARIES}) + target_include_directories( + ${LIB_TARGET} + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/assets + ${LIB_PRIVATE_INCLUDES} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${LIB_PUBLIC_INCLUDES} + ) + target_compile_definitions( + ${LIB_TARGET} + PRIVATE ${LIB_FLAGS} + CMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}" + CMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" + ) - # - # Move the library into fakeroot/bin/ directory for Windows and other - # DLL platforms so executables can be ran directly. - # - set_target_properties( - ${LIB_TARGET} - PROPERTIES - PREFIX "" - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - ) - foreach (c ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${c} cu) - set_target_properties( - ${LIB_TARGET} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY_${cu} ${CMAKE_BINARY_DIR}/bin/${c} - ) - endforeach () - - malikania_vera_check(${LIB_TARGET} "${LIB_SOURCES}") + # + # Move the library into fakeroot/bin/ directory for Windows and other + # DLL platforms so executables can be ran directly. + # + set_target_properties( + ${LIB_TARGET} + PROPERTIES + PREFIX "" + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + ) + foreach (c ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${c} cu) + set_target_properties( + ${LIB_TARGET} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY_${cu} ${CMAKE_BINARY_DIR}/bin/${c} + ) + endforeach () endfunction() diff -r 3107ce017c3a -r 387f6b0a5420 cmake/function/MalikaniaDefineTest.cmake --- a/cmake/function/MalikaniaDefineTest.cmake Fri Oct 19 20:18:19 2018 +0200 +++ b/cmake/function/MalikaniaDefineTest.cmake Fri Oct 19 20:27:02 2018 +0200 @@ -21,11 +21,11 @@ # --------------------- # # malikania_create_test( -# NAME Test name (must be lowercase) -# SOURCES Test sources files -# LIBRARIES (Optional) Libraries to link to -# RESOURCES (Optional) Resources files to copy verbatim -# FLAGS (Optional) Add list of compile definitions +# NAME Test name (must be lowercase) +# SOURCES Test sources files +# LIBRARIES (Optional) Libraries to link to +# RESOURCES (Optional) Resources files to copy verbatim +# FLAGS (Optional) Add list of compile definitions # ) # # This will generate a target named test- where name is the parameter NAME. The test is created @@ -34,81 +34,75 @@ include(CMakeParseArguments) -include(${CMAKE_CURRENT_LIST_DIR}/MalikaniaVeraCheck.cmake) +function(malikania_create_test) + set(singleArgs NAME) + set(multiArgs FLAGS LIBRARIES SOURCES RESOURCES) -function(malikania_create_test) - set(singleArgs NAME) - set(multiArgs FLAGS LIBRARIES SOURCES RESOURCES) - - cmake_parse_arguments(TEST "" "${singleArgs}" "${multiArgs}" ${ARGN}) + cmake_parse_arguments(TEST "" "${singleArgs}" "${multiArgs}" ${ARGN}) - if (NOT TEST_NAME) - message(FATAL_ERROR "Missing NAME parameter") - endif () - if (NOT TEST_SOURCES) - message(FATAL_ERROR "Missing SOURCES parameter") - endif () + if (NOT TEST_NAME) + message(FATAL_ERROR "Missing NAME parameter") + endif () + if (NOT TEST_SOURCES) + message(FATAL_ERROR "Missing SOURCES parameter") + endif () - file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/test/${TEST_NAME}) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/test/${TEST_NAME}) - if (UNIX) - list(APPEND TEST_LIBRARIES pthread) - endif () + if (UNIX) + list(APPEND TEST_LIBRARIES pthread) + endif () - # Resources files added before as custom output - foreach (f ${TEST_RESOURCES}) - get_filename_component(absolute ${f} ABSOLUTE) - file(RELATIVE_PATH basename ${CMAKE_CURRENT_SOURCE_DIR} ${absolute}) - set(output ${CMAKE_BINARY_DIR}/test/${TEST_NAME}/${basename}) + # Resources files added before as custom output + foreach (f ${TEST_RESOURCES}) + get_filename_component(absolute ${f} ABSOLUTE) + file(RELATIVE_PATH basename ${CMAKE_CURRENT_SOURCE_DIR} ${absolute}) + set(output ${CMAKE_BINARY_DIR}/test/${TEST_NAME}/${basename}) - add_custom_command( - OUTPUT ${output} - COMMAND ${CMAKE_COMMAND} -E copy ${absolute} ${output} - DEPENDS ${absolute} - ) + add_custom_command( + OUTPUT ${output} + COMMAND ${CMAKE_COMMAND} -E copy ${absolute} ${output} + DEPENDS ${absolute} + ) - list(APPEND TEST_SOURCES ${absolute}) - list(APPEND outputs ${output}) - endforeach () + list(APPEND TEST_SOURCES ${absolute}) + list(APPEND outputs ${output}) + endforeach () - add_executable(test-${TEST_NAME} ${TEST_SOURCES} ${outputs}) - source_group(private\\Resources FILES ${outputs}) - target_compile_definitions( - test-${TEST_NAME} - PRIVATE - BOOST_TEST_DYN_LINK - CMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}" - CMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" - ${TEST_FLAGS} - ) + add_executable(test-${TEST_NAME} ${TEST_SOURCES} ${outputs}) + source_group(private\\Resources FILES ${outputs}) + target_compile_definitions( + test-${TEST_NAME} + PRIVATE + BOOST_TEST_DYN_LINK + CMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}" + CMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" + ${TEST_FLAGS} + ) - set_target_properties( - test-${TEST_NAME} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - ) - foreach (c ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${c} cu) - set_target_properties( - test-${TEST_NAME} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY_${cu} ${CMAKE_BINARY_DIR}/bin/${c} - ) - endforeach () - add_test( - NAME ${TEST_NAME} - COMMAND $ - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test/${TEST_NAME} - ) + set_target_properties( + test-${TEST_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + ) + foreach (c ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${c} cu) + set_target_properties( + test-${TEST_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY_${cu} ${CMAKE_BINARY_DIR}/bin/${c} + ) + endforeach () + add_test( + NAME ${TEST_NAME} + COMMAND $ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test/${TEST_NAME} + ) - target_link_libraries( - test-${TEST_NAME} - ${TEST_LIBRARIES} - Boost::boost - Boost::unit_test_framework - ) - - add_dependencies(tests test-${TEST_NAME}) - - malikania_vera_check(test-${TEST_NAME} "${TEST_SOURCES}") + target_link_libraries( + test-${TEST_NAME} + ${TEST_LIBRARIES} + Boost::boost + Boost::unit_test_framework + ) endfunction() diff -r 3107ce017c3a -r 387f6b0a5420 cmake/function/MalikaniaSetg.cmake --- a/cmake/function/MalikaniaSetg.cmake Fri Oct 19 20:18:19 2018 +0200 +++ b/cmake/function/MalikaniaSetg.cmake Fri Oct 19 20:27:02 2018 +0200 @@ -26,5 +26,5 @@ # macro(malikania_setg var value) - set(${var} ${value} CACHE INTERNAL "" FORCE) + set(${var} ${value} CACHE INTERNAL "" FORCE) endmacro() diff -r 3107ce017c3a -r 387f6b0a5420 cmake/function/MalikaniaVeraCheck.cmake --- a/cmake/function/MalikaniaVeraCheck.cmake Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -# -# MalikaniaVeraCheck.cmake -- CMake build system for malikania -# -# Copyright (c) 2013-2018 David Demelier -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -# -# malikania_vera_check -# -------------------- -# -# malikania_vera_check(target sources) -# -# Check the style source code using vera++. -# -# No-op if WITH_VERA is Off. -# -# This macro add a post-build command to call vera++ program on the specified -# sources file for the given target. -# - -function(malikania_vera_check target sources) - if (WITH_VERA) - set(valid ".cpp;.c;.hpp;.h") - - # Cleanup non relevant files. - foreach (s ${sources}) - get_filename_component(ext ${s} EXT) - - foreach (e ${valid}) - if (${ext} STREQUAL ${e}) - list(APPEND newsources ${s}) - endif () - endforeach () - endforeach () - - add_custom_command( - TARGET ${target} - COMMAND - ${VERA_EXECUTABLE} -w --root ${CMAKE_SOURCE_DIR}/vera ${newsources} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - VERBATIM - ) - endif () -endfunction() diff -r 3107ce017c3a -r 387f6b0a5420 vera/profiles/default --- a/vera/profiles/default Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -rule=L001 -rule=L002 -rule=L003 -rule=L004 -parameter=max-line-length=120 -rule=L005 -parameter=max-consecutive-empty-lines=1 -rule=T003 -rule=T004 -rule=T005 -rule=T006 -rule=T008 -rule=T017 -rule=T018 -rule=T019 diff -r 3107ce017c3a -r 387f6b0a5420 vera/rules/L001.tcl --- a/vera/rules/L001.tcl Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -#!/usr/bin/tclsh -# No trailing whitespace - -set strictMode [getParameter "strict-trailing-space" 0] - -foreach f [getSourceFileNames] { - set lineNumber 1 - set previousIndent "" - foreach line [getAllLines $f] { - - if [regexp {^.*\r$} $line] { - report $f $lineNumber "CRLF line ending" - set line [string range $line 0 end-1] - } - if [regexp {^.*[[:space:]]+$} $line] { - if {$strictMode || [string trim $line] != "" || $line != $previousIndent} { - report $f $lineNumber "trailing whitespace" - } - } - - regexp {^([[:space:]]*).*$} $line dummy previousIndent - incr lineNumber - } -} diff -r 3107ce017c3a -r 387f6b0a5420 vera/rules/L002.tcl --- a/vera/rules/L002.tcl Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -#!/usr/bin/tclsh -# Don't use tab characters - -foreach f [getSourceFileNames] { - set lineNumber 1 - foreach line [getAllLines $f] { - - if [regexp {\t} $line] { - report $f $lineNumber "horizontal tab used" - } - - incr lineNumber - } -} diff -r 3107ce017c3a -r 387f6b0a5420 vera/rules/L003.tcl --- a/vera/rules/L003.tcl Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -#!/usr/bin/tclsh -# No leading and no trailing empty lines - -foreach f [getSourceFileNames] { - set lineCount [getLineCount $f] - if {$lineCount > 0} { - set firstLine [getLine $f 1] - if {[string trim $firstLine] == ""} { - report $f 1 "leading empty line(s)" - } - - set lastLine [getLine $f $lineCount] - if {[string trim $lastLine] == ""} { - report $f $lineCount "trailing empty line(s)" - } - } -} diff -r 3107ce017c3a -r 387f6b0a5420 vera/rules/L004.tcl --- a/vera/rules/L004.tcl Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -#!/usr/bin/tclsh -# Line cannot be too long - -set maxLength [getParameter "max-line-length" 100] - -foreach f [getSourceFileNames] { - set lineNumber 1 - foreach line [getAllLines $f] { - if {[string length $line] > $maxLength} { - report $f $lineNumber "line is longer than ${maxLength} characters" - } - incr lineNumber - } -} diff -r 3107ce017c3a -r 387f6b0a5420 vera/rules/L005.tcl --- a/vera/rules/L005.tcl Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -#!/usr/bin/tclsh -# There should not be too many consecutive empty lines - -set maxEmptyLines [getParameter "max-consecutive-empty-lines" 2] - -foreach f [getSourceFileNames] { - set lineNumber 1 - set emptyCount 0 - set reported false - foreach line [getAllLines $f] { - if {[string trim $line] == ""} { - incr emptyCount - if {$emptyCount > $maxEmptyLines && $reported == "false"} { - report $f $lineNumber "too many consecutive empty lines" - set reported true - } - } else { - set emptyCount 0 - set reported false - } - incr lineNumber - } -} diff -r 3107ce017c3a -r 387f6b0a5420 vera/rules/T003.tcl --- a/vera/rules/T003.tcl Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -#!/usr/bin/tclsh -# Some keywords should be followed by a single space - -set keywords { - case - class - enum - explicit - extern - goto - new - struct - union - using -} - -proc isKeyword {s} { - global keywords - return [expr [lsearch $keywords $s] != -1] -} - -set state "other" -foreach f [getSourceFileNames] { - foreach t [getTokens $f 1 0 -1 -1 {}] { - set tokenValue [lindex $t 0] - set tokenName [lindex $t 3] - if {$state == "keyword"} { - if {$tokenName == "space" && $tokenValue == " "} { - set state "space" - } else { - report $f $lineNumber "keyword \'${keywordValue}\' not followed by a single space" - set state "other" - } - } elseif {$state == "space"} { - if {$tokenName == "newline"} { - report $f $lineNumber "keyword \'${keywordValue}\' not followed by a single space" - } - set state "other" - } else { - if [isKeyword $tokenName] { - set state "keyword" - set lineNumber [lindex $t 1] - set keywordValue [lindex $t 0] - } - } - } -} diff -r 3107ce017c3a -r 387f6b0a5420 vera/rules/T004.tcl --- a/vera/rules/T004.tcl Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -#!/usr/bin/tclsh -# Some keywords should be immediately followed by a colon - -set keywords { - default - private - protected - public -} - -proc isKeyword {s} { - global keywords - return [expr [lsearch $keywords $s] != -1] -} - -foreach f [getSourceFileNames] { - set lastKeywordLine 0 - set lastKeywordColumn 0 - set lastKeywordValue "" - set last "" - foreach t [getTokens $f 1 0 -1 -1 [concat $keywords colon]] { - set tokenValue [lindex $t 0] - set tokenName [lindex $t 3] - if {$tokenName == "colon"} { - if {$last == "keyword" && $lastKeywordLine != 0} { - set line [lindex $t 1] - set column [lindex $t 2] - if {$line != $lastKeywordLine || - $column != [expr $lastKeywordColumn + [string length $lastKeywordValue]]} { - set nonWhiteFound "false" - foreach tb [getTokens $f $lastKeywordLine [expr $lastKeywordColumn + 1] $line $column {}] { - set tbName [lindex $tb 3] - if {[lsearch {space newline ccomment cppcomment} $tbName] == -1} { - set nonWhiteFound "true" - break - } - } - if {$nonWhiteFound == "false"} { - report $f $line "colon not immediately after the \'$lastKeywordValue\' keyword" - } - } - } - set last "colon" - } else { - set lastKeywordLine [lindex $t 1] - set lastKeywordColumn [lindex $t 2] - set lastKeywordValue $tokenValue - set last "keyword" - } - } -} diff -r 3107ce017c3a -r 387f6b0a5420 vera/rules/T005.tcl --- a/vera/rules/T005.tcl Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -#!/usr/bin/tclsh -# Keywords break and continue should be immediately followed by a semicolon - -foreach f [getSourceFileNames] { - foreach t [getTokens $f 1 0 -1 -1 {break continue}] { - set keyword [lindex $t 0] - set line [lindex $t 1] - set column [lindex $t 2] - set semicolons [getTokens $f $line [expr $column + [string length $keyword]] [expr $line + 1] 0 {semicolon}] - if {$semicolons == {}} { - report $f $line "keyword '${keyword}' not immediately followed by a semicolon" - } else { - set semColumn [lindex [lindex $semicolons 0] 2] - if {$semColumn != $column + [string length $keyword]} { - report $f $line "keyword '${keyword}' not immediately followed by a semicolon" - } - } - } -} diff -r 3107ce017c3a -r 387f6b0a5420 vera/rules/T006.tcl --- a/vera/rules/T006.tcl Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -#!/usr/bin/tclsh -# Keywords return and throw should be immediately followed by a semicolon or a single space - -foreach f [getSourceFileNames] { - foreach t [getTokens $f 1 0 -1 -1 {return throw}] { - set keyword [lindex $t 0] - set line [lindex $t 1] - set column [lindex $t 2] - set followingTokens [getTokens $f $line [expr $column + [string length $keyword]] [expr $line + 1] 0 {}] - if {$followingTokens == {}} { - report $f $line "keyword '${keyword}' not immediately followed by a semicolon or a single space" - } else { - set first [lindex [lindex $followingTokens 0] 0] - if {$first != ";" && $first != " "} { - if {!([llength $followingTokens] >= 2 && $keyword == "throw" && $first == "(" && [lindex [lindex $followingTokens 1] 0] == ")")} { - report $f $line "keyword '${keyword}' not immediately followed by a semicolon or a single space" - } - } - } - } -} diff -r 3107ce017c3a -r 387f6b0a5420 vera/rules/T008.tcl --- a/vera/rules/T008.tcl Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -#!/usr/bin/tclsh -# Keywords catch, for, if and while should be followed by a single space - -foreach f [getSourceFileNames] { - set pp_pragma_line -1 - foreach t [getTokens $f 1 0 -1 -1 {catch for if switch while pp_pragma}] { - set keyword [lindex $t 0] - set line [lindex $t 1] - set column [lindex $t 2] - set type [lindex $t 3] - if {$type == "pp_pragma"} { - set pp_pragma_line $line - } elseif {$pp_pragma_line != $line} { - set followingTokens [getTokens $f $line [expr $column + [string length $keyword]] [expr $line + 1] -1 {}] - if {[llength $followingTokens] < 2} { - report $f $line "keyword '${keyword}' not followed by a single space" - } else { - if {[list [lindex [lindex $followingTokens 0] 0] [lindex [lindex $followingTokens 1] 0]] != [list " " "("]} { - report $f $line "keyword '${keyword}' not followed by a single space" - } - } - } - } -} diff -r 3107ce017c3a -r 387f6b0a5420 vera/rules/T017.tcl --- a/vera/rules/T017.tcl Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -#!/usr/bin/tclsh -# Unnamed namespaces are not allowed in header files - -foreach fileName [getSourceFileNames] { - set extension [file extension $fileName] - if {[lsearch {.h .hh .hpp .hxx .ipp} $extension] != -1} { - - set state "start" - foreach token [getTokens $fileName 1 0 -1 -1 {namespace identifier leftbrace}] { - set type [lindex $token 3] - - if {$state == "namespace" && $type == "leftbrace"} { - report $fileName $namespaceLine "unnamed namespace not allowed in header file" - } - - if {$type == "namespace"} { - set namespaceLine [lindex $token 1] - } - - set state $type - } - } -} diff -r 3107ce017c3a -r 387f6b0a5420 vera/rules/T018.tcl --- a/vera/rules/T018.tcl Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -#!/usr/bin/tclsh -# using namespace are not allowed in header files - -foreach fileName [getSourceFileNames] { - set extension [file extension $fileName] - if {[lsearch {.h .hh .hpp .hxx .ipp} $extension] != -1} { - - set state "start" - foreach token [getTokens $fileName 1 0 -1 -1 {using namespace identifier}] { - set type [lindex $token 3] - - if {$state == "using" && $type == "namespace"} { - report $fileName $usingLine "using namespace not allowed in header file" - } - - if {$type == "using"} { - set usingLine [lindex $token 1] - } - - set state $type - } - } -} diff -r 3107ce017c3a -r 387f6b0a5420 vera/rules/T019.tcl --- a/vera/rules/T019.tcl Fri Oct 19 20:18:19 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -#!/usr/bin/tclsh -# control structures should have complete curly-braced block of code - -foreach fileName [getSourceFileNames] { - - set state "start" - set prev "" - set pp_pragma_line -1 - foreach token [getTokens $fileName 1 0 -1 -1 {for if while do else leftparen rightparen leftbrace rightbrace semicolon pp_pragma}] { - set type [lindex $token 3] - set line [lindex $token 1] - - if {$state == "control"} { - if {$type == "leftparen"} { - incr parenCount - } elseif {$type == "rightparen"} { - incr parenCount -1 - if {$parenCount == 0} { - set state "expectedblock" - } - } - - } elseif {$state == "expectedblock"} { - if {$prev == "else" && $type == "if" } { - # skip - } elseif {$type != "leftbrace"} { - set line [lindex $token 1] - report $fileName $line "full block {} expected in the control structure" - } - set state "block" - } - - if {$type == "pp_pragma"} { - set pp_pragma_line $line - } elseif {$pp_pragma_line != $line} { - if {$type == "for" || $type == "if"} { - set parenCount 0 - set state "control" - } elseif {$type == "do" || $type == "else"} { - set state "expectedblock" - } elseif {$type == "while" && $prev != "rightbrace"} { - set parenCount 0 - set state "control" - } - } - set prev $type - } -}