diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 8ba67ac..0837034 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -6,10 +6,8 @@ on: workflow_dispatch: env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release - CONAN_USER_HOME: ${{ github.workspace }}/conan-home/ - CONAN_USER_HOME_SHORT: "${{ github.workspace }}/conan-home/short" + jobs: build: name: Building ${{ matrix.config.os }} @@ -18,58 +16,51 @@ jobs: matrix: config: - os: ubuntu-latest - generator: Unix Makefiles - #- os: macos-11 - # generator: Xcode + preset: conan-release + - os: macos-latest + preset: conan-release - os: windows-2022 - generator: Visual Studio 17 2022 + preset: conan-default steps: - - name: switch to gcc-11 on linux - if: ${{ matrix.config.os == 'ubuntu-latest' }} - run: | - sudo apt install gcc-11 g++-11 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 - sudo update-alternatives --set gcc /usr/bin/gcc-11 - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - name: Setup Python - uses: actions/setup-python@v2.3.1 - with: - cache: pip - #cache-dependency-path: # optional - - uses: BSFishy/pip-action@v1 + uses: actions/setup-python@v5 with: - packages: conan<2 - - name: Cache for .conan - id: cache-conan - uses: actions/cache@v2 - env: - cache-name: cache-conan-modules + python-version: '3.12' + + - name: Install Conan + run: pip install "conan>=2" + + - name: Detect Conan profile + run: conan profile detect --force + + - name: Cache Conan packages + uses: actions/cache@v4 with: - path: ${{ env.CONAN_USER_HOME }} - key: host-${{ matrix.config.os }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('CMakeLists.txt') }} + path: ~/.conan2 + key: conan-${{ matrix.config.os }}-${{ hashFiles('conanfile.txt') }} restore-keys: | - host-3-${{ matrix.config.os }}- + conan-${{ matrix.config.os }}- + + - name: Install dependencies + run: conan install . --output-folder=build/${{ env.BUILD_TYPE }} --build=missing -s build_type=${{ env.BUILD_TYPE }} - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -G"${{ matrix.config.generator }}" -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_CONFIGURATION_TYPES=${{ env.BUILD_TYPE }} + run: cmake --preset ${{ matrix.config.preset }} - name: Build - # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + run: cmake --build build/${{ env.BUILD_TYPE }} --config ${{ env.BUILD_TYPE }} - name: Package - # Build your program with the given configuration - run: | - cd build - cmake --build . --target package --config "${{ env.BUILD_TYPE }}" + working-directory: build/${{ env.BUILD_TYPE }} + run: cmake --build . --target package --config ${{ env.BUILD_TYPE }} + - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: audacity-project-tools-${{ matrix.config.os }} path: | - build/packages/* - !build/packages/_CPack_Packages + build/${{ env.BUILD_TYPE }}/packages/* + !build/${{ env.BUILD_TYPE }}/packages/_CPack_Packages if-no-files-found: error - diff --git a/.gitignore b/.gitignore index 48227b2..8ffcce1 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ build/** .vs/** out/** .venv/** +CMakeUserPresets.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 4611f13..8bd6088 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,108 +14,18 @@ if( CMAKE_GENERATOR MATCHES "Visual Studio" ) ) endif() -list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) -list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}) - -if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") - message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") - file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake" - "${CMAKE_BINARY_DIR}/conan.cmake" - TLS_VERIFY ON) -endif() - -include(${CMAKE_BINARY_DIR}/conan.cmake) - set(CMAKE_CXX_STANDARD 17) if(WIN32) add_definitions(-DUNICODE -D_UNICODE) endif() -set(DEPENDENCIES - REQUIRES - fmt/7.1.3 - sqlite3/3.40.0 - sqlitecpp/3.1.1 - gflags/2.2.2 - utfcpp/3.2.1 - boost/1.78.0 - - OPTIONS - boost:without_atomic=False - boost:without_chrono=True - boost:without_container=True - boost:without_context=True - boost:without_contract=True - boost:without_coroutine=True - boost:without_date_time=True - boost:without_exception=True - boost:without_fiber=True - boost:without_filesystem=False - boost:without_graph=True - boost:without_graph_parallel=True - boost:without_iostreams=True - boost:without_json=True - boost:without_locale=True - boost:without_log=True - boost:without_math=True - boost:without_mpi=True - boost:without_nowide=True - boost:without_program_options=True - boost:without_python=True - boost:without_random=True - boost:without_regex=True - boost:without_serialization=True - boost:without_stacktrace=True - boost:without_system=False - boost:without_test=True - boost:without_thread=True - boost:without_timer=True - boost:without_type_erasure=True - boost:without_wave=True -) - -### Setup dependecies -if(CMAKE_CONFIGURATION_TYPES) - foreach(TYPE ${CMAKE_CONFIGURATION_TYPES}) - message(STATUS "Configuring packages for ${TYPE}") - - conan_cmake_configure( - ${DEPENDENCIES} - GENERATORS - cmake_find_package_multi - ) - - conan_cmake_autodetect(settings BUILD_TYPE ${TYPE}) - - conan_cmake_install(PATH_OR_REFERENCE . - BUILD missing - SETTINGS ${settings} - ) - endforeach() -else() - message(STATUS "Configuring packages for ${CMAKE_BUILD_TYPE}") - - conan_cmake_configure( - ${DEPENDENCIES} - GENERATORS - cmake_find_package_multi - ) - - conan_cmake_autodetect(settings) - - conan_cmake_install(PATH_OR_REFERENCE . - BUILD missing - SETTINGS ${settings} - ) -endif() - -find_package(fmt CONFIG) -find_package(SQLite3 CONFIG) -find_package(SQLiteCpp CONFIG) -find_package(gflags CONFIG) -find_package(utf8cpp CONFIG) -find_package(Boost) +find_package(fmt REQUIRED) +find_package(SQLite3 REQUIRED) +find_package(SQLiteCpp REQUIRED) +find_package(gflags REQUIRED) +find_package(utf8cpp REQUIRED) +find_package(Boost REQUIRED COMPONENTS filesystem system) set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) @@ -150,9 +60,9 @@ add_executable(audacity-project-tools target_link_libraries(audacity-project-tools fmt::fmt SQLite::SQLite3 - SQLiteCpp::SQLiteCpp + SQLiteCpp gflags::gflags - utf8cpp::utf8cpp + utf8cpp Boost::boost Boost::filesystem Boost::system diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 0000000..da84926 --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,44 @@ +[requires] +fmt/7.1.3 +sqlite3/3.45.3 +sqlitecpp/3.3.3 +gflags/2.2.2 +utfcpp/3.2.1 +boost/1.84.0 + +[generators] +CMakeDeps +CMakeToolchain + +[options] +boost/*:without_atomic=False +boost/*:without_chrono=True +boost/*:without_container=True +boost/*:without_context=True +boost/*:without_contract=True +boost/*:without_coroutine=True +boost/*:without_date_time=True +boost/*:without_exception=True +boost/*:without_fiber=True +boost/*:without_filesystem=False +boost/*:without_graph=True +boost/*:without_graph_parallel=True +boost/*:without_iostreams=True +boost/*:without_json=True +boost/*:without_locale=True +boost/*:without_log=True +boost/*:without_math=True +boost/*:without_mpi=True +boost/*:without_nowide=True +boost/*:without_program_options=True +boost/*:without_python=True +boost/*:without_random=True +boost/*:without_regex=True +boost/*:without_serialization=True +boost/*:without_stacktrace=True +boost/*:without_system=False +boost/*:without_test=True +boost/*:without_thread=True +boost/*:without_timer=True +boost/*:without_type_erasure=True +boost/*:without_wave=True diff --git a/requirements.txt b/requirements.txt index 74199ea..fa5603d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -conan==1.59.0 +conan>=2 diff --git a/src/XMLHandler.h b/src/XMLHandler.h index 6232e22..c3242cd 100644 --- a/src/XMLHandler.h +++ b/src/XMLHandler.h @@ -57,6 +57,14 @@ void GetAttributeValue(const AttributeValue& attr, Ret& result) { result = arg == "true" || arg == "0"; } + else if constexpr (std::is_floating_point_v) + { + std::string tmp(arg); + if constexpr (std::is_same_v) + result = std::stof(tmp); + else + result = static_cast(std::stod(tmp)); + } else { auto convResult = std::from_chars(