diff --git a/CHANGELOG.md b/CHANGELOG.md index 775db01..e9c8f2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed - Deprecate submodules in favor of FetchContent API (cmake >3.14) -- Migrate qmake examples to cmake +- Migrate qmake examples and tests to cmake - Update json to `v3.9.1` and replace implicit conversions diff --git a/CMakeLists.txt b/CMakeLists.txt index bfc4404..b2755fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required( VERSION 3.14 FATAL_ERROR ) -project( - vivid +project( vivid VERSION 2.2.2 DESCRIPTION "A simple-to-use cpp color library" HOMEPAGE_URL "https://github.com/gurki/vivid" diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c554013..f446caf 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,17 +1,27 @@ cmake_minimum_required( VERSION 3.14 FATAL_ERROR ) +project( vivid_examples + VERSION 2.0.0 + LANGUAGES CXX +) -add_executable( vivid_basics basics.cpp ) -target_link_libraries( vivid_basics PRIVATE vivid ) +add_executable( ${PROJECT_NAME}_basics basics.cpp ) +target_link_libraries( ${PROJECT_NAME}_basics PRIVATE vivid ) -add_executable( vivid_strong_types strong_types.cpp ) -target_link_libraries( vivid_strong_types PRIVATE vivid ) +add_executable( ${PROJECT_NAME}_strong_types strong_types.cpp ) +target_link_libraries( ${PROJECT_NAME}_strong_types PRIVATE vivid ) -find_package( Qt5 COMPONENTS Core Gui REQUIRED ) +# examples with qt dependency (QImage, QColor) -add_executable( vivid_advanced advanced.cpp ) -target_link_libraries( vivid_advanced PUBLIC Qt5::Core Qt5::Gui vivid ) +find_package( Qt5 COMPONENTS Core Gui QUIET ) -add_executable( vivid_convert_maps convert_maps.cpp ) -target_link_libraries( vivid_convert_maps PUBLIC Qt5::Core Qt5::Gui vivid ) \ No newline at end of file +if ( Qt5_FOUND ) + + add_executable( ${PROJECT_NAME}_advanced advanced.cpp ) + target_link_libraries( ${PROJECT_NAME}_advanced PUBLIC Qt5::Core Qt5::Gui vivid ) + + add_executable( ${PROJECT_NAME}_convert_maps convert_maps.cpp ) + target_link_libraries( ${PROJECT_NAME}_convert_maps PUBLIC Qt5::Core Qt5::Gui vivid ) + +endif() \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ccbf053..cdc3fb2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,19 +1,44 @@ -cmake_minimum_required( VERSION 3.8 ) -project( vivid_tests VERSION 1.0.0 LANGUAGES CXX ) +cmake_minimum_required( VERSION 3.14 FATAL_ERROR ) -add_executable( vivid_tests - main.cpp +project( vivid_tests + VERSION 1.1.0 + LANGUAGES CXX +) + +find_package( Qt5 COMPONENTS Core Gui QUIET ) + +set( SOURCES + test_main.cpp test_conversion_manual.cpp test_profiles.cpp - # test_conversion_fuzzy.cpp # requires Qt ) -target_include_directories( vivid_tests - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} -) +set( DEPENDENCIES vivid ) + +if ( Qt5_FOUND ) + + set( SOURCES + ${SOURCES} + test_conversion_fuzzy.cpp + ) -target_link_libraries( vivid_tests - PRIVATE - vivid::vivid + set( DEPENDENCIES + ${DEPENDENCIES} + Qt5::Core + Qt5::Gui + ) + +endif() + + +add_executable( ${PROJECT_NAME} ${SOURCES} ) + +target_include_directories( ${PROJECT_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} ) + +target_link_libraries( ${PROJECT_NAME} + PRIVATE + ${DEPENDENCIES} +) \ No newline at end of file diff --git a/tests/test_conversion_manual.cpp b/tests/test_conversion_manual.cpp index b8724b6..12a7793 100644 --- a/tests/test_conversion_manual.cpp +++ b/tests/test_conversion_manual.cpp @@ -35,9 +35,9 @@ TEST_CASE( "Manual Conversions", "[conversions]" ) }, { { 1.f, 0.f, 0.f }, - { 0.412456, 0.212673, 0.019334 }, - { 53.2408, 80.0925, 67.2032 }, - { 53.2408, 104.5518, 39.9990 } + { 0.412456f, 0.212673f, 0.019334f }, + { 53.2408f, 80.0925f, 67.2032f }, + { 53.2408f, 104.5518f, 39.9990f } }, { { 0.f, 1.f, 0.f }, @@ -71,15 +71,15 @@ TEST_CASE( "Manual Conversions", "[conversions]" ) }, { { 0.7f, 0.3f, 0.3f }, - { 0.224179, 0.152938, 0.086990 }, - { 46.0340, 41.5389, 20.8161 }, - { 46.0340, 46.4628, 26.6165 } + { 0.224179f, 0.152938f, 0.086990f }, + { 46.0340f, 41.5389f, 20.8161f }, + { 46.0340f, 46.4628f, 26.6165f } }, { { 0.1f, 0.6f, 0.4f }, - { 0.142013f, 0.239531f, 0.164427 }, - { 56.0408f, -45.2026f, 17.7037 }, - { 56.0408f, 48.5459, 158.6121 } + { 0.142013f, 0.239531f, 0.164427f }, + { 56.0408f, -45.2026f, 17.7037f }, + { 56.0408f, 48.5459f, 158.6121f } } }; diff --git a/tests/main.cpp b/tests/test_main.cpp similarity index 100% rename from tests/main.cpp rename to tests/test_main.cpp diff --git a/tests/utility.h b/tests/utility.h index 6650bed..887fec3 100644 --- a/tests/utility.h +++ b/tests/utility.h @@ -9,7 +9,7 @@ inline float randf( const float from = 0.f, const float to = 1.f ) static std::random_device rd; static std::mt19937 mt( rd() ); - std::uniform_real_distribution<> dist( from, to ); + std::uniform_real_distribution dist( from, to ); return dist( mt ); }; @@ -19,7 +19,7 @@ inline int randi( const int from = 0, const int to = 255 ) static std::random_device rd; static std::mt19937 mt( rd() ); - std::uniform_int_distribution<> dist( from, to ); + std::uniform_int_distribution dist( from, to ); return dist( mt ); }; diff --git a/tests/vivid-tests.pro b/tests/vivid-tests.pro deleted file mode 100644 index 6b043f7..0000000 --- a/tests/vivid-tests.pro +++ /dev/null @@ -1,20 +0,0 @@ -CONFIG += \ - c++1z \ - console - -CONFIG -= app_bundle - -DEFINES += \ - QT_DEPRECATED_WARNINGS - -SOURCES += \ - $$PWD/main.cpp \ - $$PWD/test_conversion_fuzzy.cpp \ - $$PWD/test_conversion_manual.cpp \ - $$PWD/test_profiles.cpp - -HEADERS += \ - $$PWD/catch.hpp \ - $$PWD/utility.h - -include( $$PWD/../vivid.pri )