diff --git a/.travis.yml b/.travis.yml index 5cf8e60e..464578b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,7 +63,7 @@ matrix: - 'bash .ci/run_codecov.sh' script: - .ci/make_and_test.sh 14 -DUNITS_HEADER_ONLY=ON - + # GCC 7 test2 (8 does not support lcov, wait till 9 and new lcov) - compiler: gcc env: @@ -88,7 +88,6 @@ matrix: - .ci/make_and_test.sh 17 - .ci/make_and_test.sh 11 - # GCC 4.8 - compiler: gcc env: diff --git a/CMakeLists.txt b/CMakeLists.txt index 3265a41e..5fb620dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,22 +41,26 @@ endif() # Set the build output paths if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH - "Archive output dir." + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY + "${CMAKE_BINARY_DIR}/lib" + CACHE PATH "Archive output dir." ) endif() if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH - "Library output dir." + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY + "${CMAKE_BINARY_DIR}/lib" + CACHE PATH "Library output dir." ) endif() if(NOT CMAKE_PDB_OUTPUT_DIRECTORY) - set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" + set(CMAKE_PDB_OUTPUT_DIRECTORY + "${CMAKE_BINARY_DIR}/bin" CACHE PATH "PDB (MSVC debug symbol)output dir." ) endif() if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY + "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Executable/dll output dir." ) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1bfa0cef..56c77ad8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -51,8 +51,7 @@ else() test_unit_strings PUBLIC -DTEST_FILE_FOLDER="${TEST_FILE_FOLDER}" ) - - if (NOT UNITS_BUILD_SHARED_LIBRARY) + if(NOT UNITS_BUILD_SHARED_LIBRARY) target_compile_definitions( test_unit_strings PUBLIC -DENABLE_UNIT_TESTING=1 -DENABLE_UNIT_MAP_ACCESS=1 ) diff --git a/test/find_package_tests/CMakeLists.txt b/test/find_package_tests/CMakeLists.txt index a13f3b0d..887051fa 100644 --- a/test/find_package_tests/CMakeLists.txt +++ b/test/find_package_tests/CMakeLists.txt @@ -25,14 +25,18 @@ if(UNITS_BUILD_SHARED_LIBRARY) target_link_libraries(shared-library-test-exe UNITS::units) add_test(NAME shared-library-test COMMAND shared-library-test-exe) - set_property(TEST shared-library-test PROPERTY PASS_REGULAR_EXPRESSION "${HELICS_VERSION}") + set_property( + TEST shared-library-test PROPERTY PASS_REGULAR_EXPRESSION "${HELICS_VERSION}" + ) -# Test the C and C++98 targets + # Test the C and C++98 targets elseif(UNITS_HEADER_ONLY) add_executable(header_only-exe ../pkg_test_code/header_only.cpp) target_link_libraries(header_only-exe UNITS::units) add_test(NAME header_only-exe COMMAND header_only-exe) - set_property(TEST c-shared-library-test PROPERTY PASS_REGULAR_EXPRESSION "${HELICS_VERSION}") + set_property( + TEST c-shared-library-test PROPERTY PASS_REGULAR_EXPRESSION "${HELICS_VERSION}" + ) endif() diff --git a/test/pkg_test_code/header_only.cpp b/test/pkg_test_code/header_only.cpp index aedc18e3..e20ae555 100644 --- a/test/pkg_test_code/header_only.cpp +++ b/test/pkg_test_code/header_only.cpp @@ -1,8 +1,8 @@ /* Copyright (c) 2019, -Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Sustainable -Energy, LLC. See the top-level NOTICE for additional details. All rights reserved. -SPDX-License-Identifier: BSD-3-Clause +Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance +for Sustainable Energy, LLC. See the top-level NOTICE for additional details. +All rights reserved. SPDX-License-Identifier: BSD-3-Clause */ #include "helics/helics.h" diff --git a/test/pkg_test_code/main.cpp b/test/pkg_test_code/main.cpp index 714ad357..1648e1d5 100644 --- a/test/pkg_test_code/main.cpp +++ b/test/pkg_test_code/main.cpp @@ -1,8 +1,8 @@ /* Copyright (c) 2021, -Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Sustainable -Energy, LLC. See the top-level NOTICE for additional details. All rights reserved. -SPDX-License-Identifier: BSD-3-Clause +Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance +for Sustainable Energy, LLC. See the top-level NOTICE for additional details. +All rights reserved. SPDX-License-Identifier: BSD-3-Clause */ #include "units/units.hpp" @@ -13,6 +13,6 @@ int main(int /*argc*/, char* /*argv*/[]) { auto u1 = units::measurement_from_string("10.7 meters per second"); - std::cout << u1 << std::endl; + std::cout << u1 << std::endl; return 0; } diff --git a/units/CMakeLists.txt b/units/CMakeLists.txt index ce6ee45e..cb7c0036 100644 --- a/units/CMakeLists.txt +++ b/units/CMakeLists.txt @@ -11,43 +11,38 @@ set(units_header_files units.hpp units_decl.hpp unit_definitions.hpp units_util. include(GenerateExportHeader) if(UNITS_BUILD_SHARED_LIBRARY OR BUILD_SHARED_LIBS) - add_library(units SHARED ${units_source_files} ${units_header_files}) - generate_export_header(units BASE_NAME units) - target_compile_definitions(units PUBLIC UNITS_EXPORT_HEADER) - target_include_directories( - units - PUBLIC $ - $ - $ + add_library(units SHARED ${units_source_files} ${units_header_files}) + generate_export_header(units BASE_NAME units) + target_compile_definitions(units PUBLIC UNITS_EXPORT_HEADER) + target_include_directories( + units + PUBLIC $ + $ + $ + ) + target_link_libraries(units PRIVATE compile_flags_target) + + if(UNITS_NAMESPACE) + target_compile_definitions(units PUBLIC -DUNITS_NAMESPACE=${UNITS_NAMESPACE}) + endif() + if(UNITS_BASE_TYPE) + target_compile_definitions(units PUBLIC -DUNITS_BASE_TYPE=${UNITS_BASE_TYPE}) + endif() + if(UNITS_INSTALL) + install( + TARGETS units ${UNITS_LIBRARY_EXPORT_COMMAND} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # INCLUDES DESTINATION + # include/units ) - target_link_libraries(units PRIVATE compile_flags_target) - - - if(UNITS_NAMESPACE) - target_compile_definitions( - units PUBLIC -DUNITS_NAMESPACE=${UNITS_NAMESPACE} - ) - endif() - if(UNITS_BASE_TYPE) - target_compile_definitions( - units PUBLIC -DUNITS_BASE_TYPE=${UNITS_BASE_TYPE} - ) - endif() - if(UNITS_INSTALL) - install( - TARGETS units ${UNITS_LIBRARY_EXPORT_COMMAND} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # INCLUDES DESTINATION - # include/units - ) - endif() - add_library(units::units ALIAS units) + endif() + add_library(units::units ALIAS units) elseif(UNITS_HEADER_ONLY) add_library(header_only INTERFACE) target_include_directories( header_only INTERFACE $ - $ + $ ) target_compile_definitions(header_only INTERFACE UNITS_HEADER_ONLY) if(UNITS_INSTALL) @@ -63,70 +58,60 @@ elseif(UNITS_HEADER_ONLY) header_only INTERFACE -DUNITS_BASE_TYPE=${UNITS_BASE_TYPE} ) endif() - add_library(units::header_only ALIAS header_only) + add_library(units::header_only ALIAS header_only) elseif(UNITS_BUILD_OBJECT_LIBRARY) - add_library(units OBJECT ${units_source_files} ${units_header_files}) - target_include_directories( - units PRIVATE $ - ) + add_library(units OBJECT ${units_source_files} ${units_header_files}) + target_include_directories(units PRIVATE $) - if(UNITS_NAMESPACE) - target_compile_definitions( - units PUBLIC -DUNITS_NAMESPACE=${UNITS_NAMESPACE} - ) - - if(UNITS_BASE_TYPE) - target_compile_definitions( - units PUBLIC -DUNITS_BASE_TYPE=${UNITS_BASE_TYPE} - ) - endif() - endif() - else() - add_library(units STATIC ${units_source_files} ${units_header_files}) - target_include_directories( - units - PUBLIC $ - $ - $ - ) - target_link_libraries(units PRIVATE compile_flags_target) + if(UNITS_NAMESPACE) + target_compile_definitions(units PUBLIC -DUNITS_NAMESPACE=${UNITS_NAMESPACE}) - if(UNITS_ENABLE_TESTS) - target_compile_definitions( - units PUBLIC -DENABLE_UNIT_TESTING=1 -DENABLE_UNIT_MAP_ACCESS=1 - ) - endif() - if(UNITS_NAMESPACE) - target_compile_definitions( - units PUBLIC -DUNITS_NAMESPACE=${UNITS_NAMESPACE} - ) - endif() if(UNITS_BASE_TYPE) target_compile_definitions( units PUBLIC -DUNITS_BASE_TYPE=${UNITS_BASE_TYPE} ) endif() - if(UNITS_INSTALL) - install(TARGETS units ${UNITS_LIBRARY_EXPORT_COMMAND} - DESTINATION ${CMAKE_INSTALL_LIBDIR} # INCLUDES DESTINATION - # include/units - ) - endif(UNITS_INSTALL) - if(CMAKE_BUILD_TYPE STREQUAL Coverage) - set_source_files_properties(foo.cpp PROPERTIES COMPILE_FLAGS -Wno-effc++) - endif() - if(UNITS_CLANG_TIDY) - set_property(TARGET units PROPERTY CXX_CLANG_TIDY "${DO_CLANG_TIDY}") - endif() - add_library(units::units ALIAS units) endif() +else() + add_library(units STATIC ${units_source_files} ${units_header_files}) + target_include_directories( + units + PUBLIC $ + $ + $ + ) + target_link_libraries(units PRIVATE compile_flags_target) - - + if(UNITS_ENABLE_TESTS) + target_compile_definitions( + units PUBLIC -DENABLE_UNIT_TESTING=1 -DENABLE_UNIT_MAP_ACCESS=1 + ) + endif() + if(UNITS_NAMESPACE) + target_compile_definitions(units PUBLIC -DUNITS_NAMESPACE=${UNITS_NAMESPACE}) + endif() + if(UNITS_BASE_TYPE) + target_compile_definitions(units PUBLIC -DUNITS_BASE_TYPE=${UNITS_BASE_TYPE}) + endif() + if(UNITS_INSTALL) + install(TARGETS units ${UNITS_LIBRARY_EXPORT_COMMAND} + DESTINATION ${CMAKE_INSTALL_LIBDIR} # INCLUDES DESTINATION include/units + ) + endif(UNITS_INSTALL) + if(CMAKE_BUILD_TYPE STREQUAL Coverage) + set_source_files_properties(foo.cpp PROPERTIES COMPILE_FLAGS -Wno-effc++) + endif() + if(UNITS_CLANG_TIDY) + set_property(TARGET units PROPERTY CXX_CLANG_TIDY "${DO_CLANG_TIDY}") + endif() + add_library(units::units ALIAS units) +endif() if(UNITS_INSTALL AND NOT UNITS_BINARY_ONLY_INSTALL) install(FILES ${units_header_files} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) if(UNITS_BUILD_SHARED_LIBRARY OR BUILD_SHARED_LIBS) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/units_export.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/units) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/units_export.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/units + ) endif() endif()