Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated formatting of repo files #156

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -88,7 +88,6 @@ matrix:
- .ci/make_and_test.sh 17
- .ci/make_and_test.sh 11


# GCC 4.8
- compiler: gcc
env:
Expand Down
16 changes: 10 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
10 changes: 7 additions & 3 deletions test/find_package_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
6 changes: 3 additions & 3 deletions test/pkg_test_code/header_only.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
8 changes: 4 additions & 4 deletions test/pkg_test_code/main.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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;
}
151 changes: 68 additions & 83 deletions units/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<BUILD_INTERFACE:${UNITS_SOURCE_DIR}>
$<BUILD_INTERFACE:${UNITS_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
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 $<BUILD_INTERFACE:${UNITS_SOURCE_DIR}>
$<BUILD_INTERFACE:${UNITS_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
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 $<BUILD_INTERFACE:${UNITS_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_definitions(header_only INTERFACE UNITS_HEADER_ONLY)
if(UNITS_INSTALL)
Expand All @@ -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 $<BUILD_INTERFACE:${UNITS_SOURCE_DIR}>
)
add_library(units OBJECT ${units_source_files} ${units_header_files})
target_include_directories(units PRIVATE $<BUILD_INTERFACE:${UNITS_SOURCE_DIR}>)

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 $<BUILD_INTERFACE:${UNITS_SOURCE_DIR}>
$<BUILD_INTERFACE:${UNITS_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
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 $<BUILD_INTERFACE:${UNITS_SOURCE_DIR}>
$<BUILD_INTERFACE:${UNITS_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
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()