From 4805162fd8a287e555f408a9bbb219c9469d4d5d Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Sun, 30 Jun 2024 10:37:38 +0200 Subject: [PATCH 1/8] Generate cmake config versioN Signed-off-by: Uilian Ries --- CMakeLists.txt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfa468bf1..0e505b86e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.22) -project(faker-cxx LANGUAGES CXX) +project(faker-cxx LANGUAGES CXX VERSION 2.0.0) include(cmake/CompilerWarnings.cmake) @@ -94,6 +94,8 @@ generate_export_header(${CMAKE_PROJECT_NAME} BASE_NAME FAKER_CXX EXPORT_FILE_NAM set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden CMAKE_VISIBILITY_INLINES_HIDDEN 1 + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} ) target_include_directories( @@ -102,7 +104,13 @@ target_include_directories( PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include ) +include(CMakePackageConfigHelpers) include(GNUInstallDirs) + +write_basic_package_version_file(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion) + install(TARGETS ${CMAKE_PROJECT_NAME} EXPORT ${CMAKE_PROJECT_NAME}-targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -121,10 +129,15 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/faker-cxx PATTERN "*.h" ) +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME} +) + install(EXPORT ${CMAKE_PROJECT_NAME}-targets NAMESPACE ${CMAKE_PROJECT_NAME}:: FILE ${CMAKE_PROJECT_NAME}-config.cmake - DESTINATION lib/cmake/${CMAKE_PROJECT_NAME}) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}) if (USE_STD_FORMAT) target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE USE_STD_FORMAT) From 480bc043e8788b758ffd9624ade65d01de23fcd6 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Sun, 30 Jun 2024 10:45:49 +0200 Subject: [PATCH 2/8] Generate version.h Signed-off-by: Uilian Ries --- CMakeLists.txt | 5 +++++ cmake/Version.h.in | 6 ++++++ include/faker-cxx/Faker.h | 1 + 3 files changed, 12 insertions(+) create mode 100644 cmake/Version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e505b86e..7299fe085 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,6 +89,11 @@ configure_compiler_warnings(${CMAKE_PROJECT_NAME} "${CLANG_WARNINGS}" "${GCC_WARNINGS}") +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Version.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/include/faker-cxx/Version.h" +) + include(GenerateExportHeader) generate_export_header(${CMAKE_PROJECT_NAME} BASE_NAME FAKER_CXX EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/include/faker-cxx/Export.h) set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES diff --git a/cmake/Version.h.in b/cmake/Version.h.in new file mode 100644 index 000000000..ddf0bd726 --- /dev/null +++ b/cmake/Version.h.in @@ -0,0 +1,6 @@ +#pragma once + +#define FAKER_CXX_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define FAKER_CXX_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define FAKER_CXX_VERSION_PATCH @PROJECT_VERSION_PATCH@ +#define FAKER_CXX_VERSION "@PROJECT_VERSION@" diff --git a/include/faker-cxx/Faker.h b/include/faker-cxx/Faker.h index 5c1d6b493..9c404d094 100644 --- a/include/faker-cxx/Faker.h +++ b/include/faker-cxx/Faker.h @@ -34,6 +34,7 @@ #include "faker-cxx/String.h" #include "faker-cxx/System.h" #include "faker-cxx/Vehicle.h" +#include "faker-cxx/Version.h" #include "faker-cxx/VideoGame.h" #include "faker-cxx/Weather.h" #include "faker-cxx/Word.h" \ No newline at end of file From 1e80078ec08ad9962f1d6b5f84e47b07db91ec27 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Sun, 30 Jun 2024 10:59:30 +0200 Subject: [PATCH 3/8] Generate version.h with Bazel Signed-off-by: Uilian Ries --- BUILD.bazel | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/BUILD.bazel b/BUILD.bazel index 8a49fc555..9cb022b47 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -10,10 +10,23 @@ genrule( """, ) +genrule( + name = "generate_version_header", + srcs = [], + outs = ["include/faker-cxx/Version.h"], + cmd = """ + echo "#pragma once" > $@ + echo '#define FAKER_CXX_VERSION_MAJOR 2' >> $@ + echo '#define FAKER_CXX_VERSION_MINOR 0' >> $@ + echo '#define FAKER_CXX_VERSION_PATCH 0' >> $@ + echo '#define FAKER_CXX_VERSION "2.0.0"' >> $@ + """, +) + cc_library( name = "faker-cxx", srcs = glob(["src/**/*.cpp"]), - hdrs = glob(["src/**/*.h", "include/**/*.h"]) + [":generate_export_header"], + hdrs = glob(["src/**/*.h", "include/**/*.h"]) + [":generate_export_header"] + [":generate_version_header"], includes = ["include", "src"], visibility = ["//visibility:public"], deps = ["@fmt//:fmt"], From 4b228cab8207ef2d5027e180154ef015292c5e45 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Sun, 30 Jun 2024 11:20:54 +0200 Subject: [PATCH 4/8] Generate .pc file Signed-off-by: Uilian Ries --- CMakeLists.txt | 22 +++++++++++++++++++--- cmake/faker-cxx.pc.in | 12 ++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 cmake/faker-cxx.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 7299fe085..8be5307e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.22) -project(faker-cxx LANGUAGES CXX VERSION 2.0.0) +project(faker-cxx + LANGUAGES CXX + VERSION 2.0.0 + DESCRIPTION "C++ Faker library for generating fake (but realistic) data." + HOMEPAGE_URL "https://github.com/cieslarmichal/faker-cxx") include(cmake/CompilerWarnings.cmake) @@ -92,6 +96,7 @@ configure_compiler_warnings(${CMAKE_PROJECT_NAME} configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/include/faker-cxx/Version.h" + @ONLY ) include(GenerateExportHeader) @@ -112,6 +117,12 @@ target_include_directories( include(CMakePackageConfigHelpers) include(GNUInstallDirs) +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}.pc.in" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" + @ONLY +) + write_basic_package_version_file(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion) @@ -134,15 +145,20 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/faker-cxx PATTERN "*.h" ) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.pc" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig +) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME} + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake ) install(EXPORT ${CMAKE_PROJECT_NAME}-targets NAMESPACE ${CMAKE_PROJECT_NAME}:: FILE ${CMAKE_PROJECT_NAME}-config.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake +) if (USE_STD_FORMAT) target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE USE_STD_FORMAT) diff --git a/cmake/faker-cxx.pc.in b/cmake/faker-cxx.pc.in new file mode 100644 index 000000000..dee088c9f --- /dev/null +++ b/cmake/faker-cxx.pc.in @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ + +Name: @PROJECT_NAME@ +Description: @PROJECT_DESCRIPTION@ +Version: @PROJECT_VERSION@ + +Requires: +Libs: -L${libdir} -lfaker-cxx +Cflags: -I${includedir} \ No newline at end of file From b65950662dec1c4d700a0fb9d451ae0f38fe2b79 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Sun, 30 Jun 2024 11:56:45 +0200 Subject: [PATCH 5/8] Split cmake files Signed-off-by: Uilian Ries --- CMakeLists.txt | 143 +++-------------------------------- src/CMakeLists.txt | 173 +++++++++++++++++++++++++++++++++++++++++++ tests/CMakeLists.txt | 2 +- 3 files changed, 184 insertions(+), 134 deletions(-) create mode 100644 src/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 8be5307e0..0d1da5be7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,144 +33,21 @@ if (BUILD_TESTING) add_code_coverage_all_targets() endif () -set(FAKER_SOURCES - src/modules/airline/Airline.cpp - src/modules/animal/Animal.cpp - src/modules/book/Book.cpp - src/modules/color/Color.cpp - src/modules/commerce/Commerce.cpp - src/modules/company/Company.cpp - src/modules/computer/Computer.cpp - src/modules/crypto/Crypto.cpp - src/modules/database/Database.cpp - src/modules/datatype/Datatype.cpp - src/modules/date/Date.cpp - src/modules/finance/Finance.cpp - src/modules/food/Food.cpp - src/modules/git/Git.cpp - src/modules/hacker/Hacker.cpp - src/modules/helper/Helper.cpp - src/modules/image/Image.cpp - src/modules/internet/Internet.cpp - src/modules/location/Location.cpp - src/modules/lorem/Lorem.cpp - src/modules/medicine/Medicine.cpp - src/modules/movie/Movie.cpp - src/modules/music/Music.cpp - src/modules/person/Person.cpp - src/modules/phone/Phone.cpp - src/modules/plant/Plant.cpp - src/modules/science/Science.cpp - src/modules/sport/Sport.cpp - src/modules/string/String.cpp - src/modules/system/System.cpp - src/modules/vehicle/Vehicle.cpp - src/modules/videoGame/VideoGame.cpp - src/modules/weather/Weather.cpp - src/modules/word/Word.cpp - src/common/FormatHelper.cpp - src/common/LuhnCheck.cpp - src/common/StringHelper.cpp -) +add_library(${CMAKE_PROJECT_NAME}) -add_library(${CMAKE_PROJECT_NAME} ${FAKER_SOURCES}) - -target_include_directories( - ${CMAKE_PROJECT_NAME} PUBLIC - $ - $ -) - -target_include_directories( - ${CMAKE_PROJECT_NAME} PRIVATE - $ -) - -target_compile_features(${CMAKE_PROJECT_NAME} PUBLIC cxx_std_20) -configure_compiler_warnings(${CMAKE_PROJECT_NAME} - "${WARNINGS_AS_ERRORS}" - "${MSVC_WARNINGS}" - "${CLANG_WARNINGS}" - "${GCC_WARNINGS}") - -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Version.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/include/faker-cxx/Version.h" - @ONLY -) - -include(GenerateExportHeader) -generate_export_header(${CMAKE_PROJECT_NAME} BASE_NAME FAKER_CXX EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/include/faker-cxx/Export.h) -set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES - CXX_VISIBILITY_PRESET hidden - CMAKE_VISIBILITY_INLINES_HIDDEN 1 - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR} -) - -target_include_directories( - ${CMAKE_PROJECT_NAME} - PUBLIC $ - PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include -) - -include(CMakePackageConfigHelpers) -include(GNUInstallDirs) - -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}.pc.in" - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" - @ONLY -) - -write_basic_package_version_file(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion) - -install(TARGETS ${CMAKE_PROJECT_NAME} - EXPORT ${CMAKE_PROJECT_NAME}-targets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/faker-cxx - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILES_MATCHING - PATTERN "*.h" -) - -install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/faker-cxx - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILES_MATCHING - PATTERN "*.h" -) - -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.pc" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig -) - -install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake -) - -install(EXPORT ${CMAKE_PROJECT_NAME}-targets - NAMESPACE ${CMAKE_PROJECT_NAME}:: - FILE ${CMAKE_PROJECT_NAME}-config.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake -) - -if (USE_STD_FORMAT) - target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE USE_STD_FORMAT) -elseif (USE_SYSTEM_DEPENDENCIES) +if (USE_SYSTEM_DEPENDENCIES) find_package(fmt CONFIG REQUIRED) - target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE fmt::fmt) -else () - add_subdirectory(externals/fmt) +elseif (NOT USE_STD_FORMAT) + find_library(FMT_LIBRARY fmt) + if (NOT FMT_LIBRARY) + message(FATAL_ERROR "Could not find fmt library. Please, read the contribution guide.") + endif() + add_subdirectory("${CMAKE_SOURCE_DIR}/externals/fmt") set(FMT_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/fmt/include") - target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE fmt) endif () +add_subdirectory(src) + if (BUILD_TESTING) add_subdirectory(tests) endif () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..99944354c --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,173 @@ +cmake_minimum_required(VERSION 3.22) + +include("${CMAKE_SOURCE_DIR}/cmake/CompilerWarnings.cmake") + +set(FAKER_SOURCES + modules/airline/Airline.cpp + modules/animal/Animal.cpp + modules/book/Book.cpp + modules/color/Color.cpp + modules/commerce/Commerce.cpp + modules/company/Company.cpp + modules/computer/Computer.cpp + modules/crypto/Crypto.cpp + modules/database/Database.cpp + modules/datatype/Datatype.cpp + modules/date/Date.cpp + modules/finance/Finance.cpp + modules/food/Food.cpp + modules/git/Git.cpp + modules/hacker/Hacker.cpp + modules/helper/Helper.cpp + modules/image/Image.cpp + modules/internet/Internet.cpp + modules/location/Location.cpp + modules/lorem/Lorem.cpp + modules/medicine/Medicine.cpp + modules/movie/Movie.cpp + modules/music/Music.cpp + modules/person/Person.cpp + modules/phone/Phone.cpp + modules/plant/Plant.cpp + modules/science/Science.cpp + modules/sport/Sport.cpp + modules/string/String.cpp + modules/system/System.cpp + modules/vehicle/Vehicle.cpp + modules/videoGame/VideoGame.cpp + modules/weather/Weather.cpp + modules/word/Word.cpp + common/FormatHelper.cpp + common/LuhnCheck.cpp + common/StringHelper.cpp +) + +set(FAKER_HEADERS + common/LuhnCheck.h + common/FormatHelper.h + common/StringHelper.h + modules/plant/PlantData.h + modules/person/PersonData.h + modules/internet/InternetData.h + modules/sport/SportData.h + modules/airline/AirlineData.h + modules/location/LocationData.h + modules/book/BookData.h + modules/string/StringData.h + modules/videoGame/VideoGameData.h + modules/medicine/MedicineData.h + modules/vehicle/VehicleData.h + modules/hacker/HackerData.h + modules/science/ScienceData.h + modules/date/DateData.h + modules/system/SystemData.h + modules/commerce/CommerceData.h + modules/computer/ComputerData.h + modules/weather/WeatherData.h + modules/music/MusicData.h + modules/database/DatabaseData.h + modules/movie/MovieData.h + modules/food/FoodData.h + modules/word/WordData.h + modules/word/WordStore.h + modules/animal/AnimalData.h + modules/company/CompanyData.h + modules/finance/FinanceData.h + modules/phone/PhoneData.h + modules/color/ColorData.h + modules/lorem/LoremData.h +) + +target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${FAKER_SOURCES} ${FAKER_HEADERS}) +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE $,fmt::fmt,${FMT_LIBRARY}>) +if (USE_STD_FORMAT) + target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE USE_STD_FORMAT) +endif() + +target_include_directories( + ${CMAKE_PROJECT_NAME} PUBLIC + $ + $ +) + +target_include_directories( + ${CMAKE_PROJECT_NAME} PRIVATE + $ +) + +target_compile_features(${CMAKE_PROJECT_NAME} PUBLIC cxx_std_20) +configure_compiler_warnings(${CMAKE_PROJECT_NAME} + "${WARNINGS_AS_ERRORS}" + "${MSVC_WARNINGS}" + "${CLANG_WARNINGS}" + "${GCC_WARNINGS}") + +configure_file( + "${CMAKE_SOURCE_DIR}/cmake/Version.h.in" + "${CMAKE_BINARY_DIR}/include/faker-cxx/Version.h" + @ONLY +) + +include(GenerateExportHeader) +generate_export_header(${CMAKE_PROJECT_NAME} + BASE_NAME FAKER_CXX + EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/include/faker-cxx/Export.h +) +set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES + CXX_VISIBILITY_PRESET hidden + CMAKE_VISIBILITY_INLINES_HIDDEN 1 + VERSION ${CMAKE_PROJECT_VERSION} + SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR} +) + +target_include_directories( + ${CMAKE_PROJECT_NAME} + PUBLIC $ + PRIVATE ${CMAKE_BINARY_DIR}/include +) + +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) + +configure_file( + "${CMAKE_SOURCE_DIR}/cmake/${CMAKE_PROJECT_NAME}.pc.in" + "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.pc" + @ONLY +) + +write_basic_package_version_file(${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake + VERSION ${CMAKE_PROJECT_VERSION} + COMPATIBILITY SameMajorVersion) + +install(TARGETS ${CMAKE_PROJECT_NAME} + EXPORT ${CMAKE_PROJECT_NAME}-targets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/faker-cxx + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING + PATTERN "*.h" +) + +install(DIRECTORY ${CMAKE_BINARY_DIR}/include/faker-cxx + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING + PATTERN "*.h" +) + +install(FILES "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.pc" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig +) + +install(FILES + "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake +) + +install(EXPORT ${CMAKE_PROJECT_NAME}-targets + NAMESPACE ${CMAKE_PROJECT_NAME}:: + FILE ${CMAKE_PROJECT_NAME}-config.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake +) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5666c0431..af0a8dfbd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -74,7 +74,7 @@ if (USE_STD_FORMAT) target_include_directories(${PROJECT_NAME} PRIVATE ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR} ${CMAKE_CURRENT_LIST_DIR}) target_compile_definitions(${PROJECT_NAME} PRIVATE USE_STD_FORMAT) else () - target_link_libraries(${PROJECT_NAME} PRIVATE $,fmt::fmt,fmt>) + target_link_libraries(${PROJECT_NAME} PRIVATE $,fmt::fmt,${FMT_LIBRARY}>) target_include_directories(${PROJECT_NAME} PRIVATE ${FMT_INCLUDE_DIR} ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR} ${CMAKE_CURRENT_LIST_DIR}) endif () From c30bd4a6f39effb5d549c897a6e43508c3428af4 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Sun, 30 Jun 2024 12:22:38 +0200 Subject: [PATCH 6/8] Add GoogleTest helper Signed-off-by: Uilian Ries --- tests/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index af0a8dfbd..a55a69615 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.22) project(${CMAKE_PROJECT_NAME}-UT CXX) include(CTest) +include(GoogleTest) include("${CMAKE_SOURCE_DIR}/cmake/CompilerWarnings.cmake") set(FAKER_UT_SOURCES @@ -40,6 +41,7 @@ set(FAKER_UT_SOURCES modules/string/StringTest.cpp modules/system/SystemTest.cpp modules/vehicle/VehicleTest.cpp + modules/version/VersionTest.cpp modules/videoGame/VideoGameTest.cpp modules/weather/WeatherTest.cpp modules/word/WordTest.cpp @@ -83,3 +85,5 @@ set_tests_properties(${PROJECT_NAME} PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<$:$>") target_code_coverage(${PROJECT_NAME} ALL) + +gtest_discover_tests(${PROJECT_NAME}) \ No newline at end of file From 9acae1de8e15836db609ce587392cce4ce5876dd Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Sun, 30 Jun 2024 12:39:19 +0200 Subject: [PATCH 7/8] Add test for version module Signed-off-by: Uilian Ries --- tests/modules/version/VersionTest.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/modules/version/VersionTest.cpp diff --git a/tests/modules/version/VersionTest.cpp b/tests/modules/version/VersionTest.cpp new file mode 100644 index 000000000..73a08e045 --- /dev/null +++ b/tests/modules/version/VersionTest.cpp @@ -0,0 +1,18 @@ +#include "faker-cxx/Version.h" + +#include "gtest/gtest.h" + +using namespace ::testing; + +class VersionTest : public Test +{ +public: +}; + +TEST_F(VersionTest, shouldGenerateVersion) +{ + ASSERT_GE(FAKER_CXX_VERSION_MAJOR, 2); + ASSERT_GE(FAKER_CXX_VERSION_MINOR, 0); + ASSERT_GE(FAKER_CXX_VERSION_PATCH, 0); + ASSERT_TRUE(FAKER_CXX_VERSION); +} From d0ad2d0c3adf6f851283a582a2ae304f8b1c4027 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Sun, 30 Jun 2024 11:06:39 +0200 Subject: [PATCH 8/8] Remove gtest_discover_tests Signed-off-by: Uilian Ries --- tests/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a55a69615..19c69d9e3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.22) project(${CMAKE_PROJECT_NAME}-UT CXX) include(CTest) -include(GoogleTest) include("${CMAKE_SOURCE_DIR}/cmake/CompilerWarnings.cmake") set(FAKER_UT_SOURCES @@ -85,5 +84,3 @@ set_tests_properties(${PROJECT_NAME} PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<$:$>") target_code_coverage(${PROJECT_NAME} ALL) - -gtest_discover_tests(${PROJECT_NAME}) \ No newline at end of file