Skip to content

Commit

Permalink
Conan --> Vcpkg (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo authored Jan 6, 2024
1 parent fccee5e commit 7693072
Show file tree
Hide file tree
Showing 18 changed files with 260,279 additions and 228 deletions.
38 changes: 18 additions & 20 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ permissions:
env:
BUILD_TYPE: Release
GITHUB_ACTIONS: true
VCPKG_ROOT: ${{github.workspace}}/vcpkg
jobs:
build:
name: ${{ matrix.config.name }}
Expand All @@ -30,34 +31,31 @@ jobs:
uses: actions/checkout@v4
with:
submodules: recursive
- name: "Setup XDG"
- name: "Setup Environment"
run: |
mkdir build
sudo apt-get install xdg-user-dirs -y
xdg-user-dirs-update
- name: "Setup Keyring"
uses: t1m0thyj/unlock-keyring@v1
- name: "Set en_US Locale"
run: |
sudo apt-get install gettext tzdata locales -y
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8
- name: "Get Conan"
uses: turtlebrowser/get-conan@main
- name: "Setup Conan Settings"
run: |
mv conan/conansettings.yml settings_user.yml
conan config install settings_user.yml
- name: "Install Conan"
run: |
mv conan/conanfile.py conanfile.py
mv conan/conanprofile-linux.txt conanprofile.txt
conan install conanfile.py --profile:host=conanprofile.txt --profile:build=conanprofile.txt -s compiler.cppstd=20 --build=missing
- name: "CMake Build"
- name: "Unlock Keyring"
uses: t1m0thyj/unlock-keyring@v1
- name: "Vcpkg"
uses: johnwason/vcpkg-action@v5
id: vcpkg
with:
pkgs: boost-locale curl gettext gettext-libintl glib gtest jsoncpp libsecret libuuid maddy openssl
triplet: x64-linux
cache-key: ${{ matrix.config.os }}
revision: f634024a30c5afa9f04d533ad5d0c0220778fd0b
token: ${{ secrets.GITHUB_TOKEN }}
- name: "Build"
working-directory: ${{github.workspace}}/build
run: |
cmake .. -DCMAKE_TOOLCHAIN_FILE="${{github.workspace}}/build/Release/generators/conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
cmake --build .
- name: "CMake Install"
- name: "Install"
working-directory: ${{github.workspace}}/build
run: cmake --install . --prefix "${{github.workspace}}/install"
- name: "Test"
Expand All @@ -66,4 +64,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
path: ${{github.workspace}}/install
name: Linux-x64-${{env.BUILD_TYPE}}
name: Linux-x64-${{env.BUILD_TYPE}}
27 changes: 16 additions & 11 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ permissions:
env:
BUILD_TYPE: Release
GITHUB_ACTIONS: true
VCPKG_ROOT: ${{github.workspace}}/vcpkg
jobs:
build:
name: ${{ matrix.config.name }}
Expand All @@ -27,19 +28,23 @@ jobs:
uses: actions/checkout@v4
with:
submodules: recursive
- name: "Get Conan"
uses: turtlebrowser/get-conan@main
- name: "Install Conan"
run: |
move conan/conanfile.py conanfile.py
move conan/conanprofile-windows.txt conanprofile.txt
conan install conanfile.py --profile:host=conanprofile.txt --profile:build=conanprofile.txt -s compiler.cppstd=20 --build=missing
- name: "CMake Build"
- name: "Setup Environment"
run: mkdir build
- name: "Vcpkg"
uses: johnwason/vcpkg-action@v5
id: vcpkg
with:
pkgs: boost-locale curl gettext gettext-libintl gtest jsoncpp maddy openssl
triplet: x64-windows
cache-key: ${{ matrix.config.os }}
revision: f634024a30c5afa9f04d533ad5d0c0220778fd0b
token: ${{ secrets.GITHUB_TOKEN }}
- name: "Build"
working-directory: ${{github.workspace}}/build
run: |
cmake .. -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="${{github.workspace}}/build/generators/conan_toolchain.cmake"
cmake -G "Visual Studio 17 2022" ..
cmake --build . --config ${{env.BUILD_TYPE}}
- name: "CMake Install"
- name: "Install"
working-directory: ${{github.workspace}}/build
run: cmake --install . --prefix "${{github.workspace}}/install"
- name: "Test"
Expand All @@ -48,4 +53,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
path: ${{github.workspace}}/install
name: Windows-x64-${{env.BUILD_TYPE}}
name: Windows-x64-${{env.BUILD_TYPE}}
174 changes: 91 additions & 83 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,113 +1,121 @@
cmake_minimum_required (VERSION 3.25)

file(TO_CMAKE_PATH $ENV{VCPKG_ROOT} VCPKG_ROOT)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(SQLITE_HAS_CODEC ON)
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
if(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(BUILD_SHARED_LIBS ON)
endif()
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()

project ("libaura" LANGUAGES CXX VERSION 2024.1.0 DESCRIPTION "A cross-platform base for native Nickvision applications.")
#libaura Definition
project ("libaura" LANGUAGES C CXX VERSION 2024.1.0 DESCRIPTION "A cross-platform base for native Nickvision applications.")
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(CTest)

#libaura Library Setup
include_directories(${PROJECT_SOURCE_DIR}/include)
#libaura Setup
add_compile_definitions(SQLITE_HAS_CODEC)
if(LINUX)
add_compile_definitions(HAVE_USLEEP)
endif()
add_library (${PROJECT_NAME}
src/filesystem/filesystemchangedeventargs.cpp
src/filesystem/filesystemwatcher.cpp
src/helpers/stringhelpers.cpp
src/helpers/webhelpers.cpp
src/keyring/credential.cpp
src/keyring/keyring.cpp
src/keyring/keyringdialogcontroller.cpp
src/keyring/passwordgenerator.cpp
src/keyring/passwordstrength.cpp
src/keyring/store.cpp
src/keyring/systemcredentials.cpp
src/localization/documentation.cpp
src/localization/gettext.cpp
src/network/networkmonitor.cpp
src/network/networkstatechangedeventargs.cpp
src/notifications/notificationsenteventargs.cpp
src/notifications/notifyicon.cpp
src/notifications/notifyiconmenu.cpp
src/notifications/shellnotification.cpp
src/notifications/shellnotificationsenteventargs.cpp
src/taskbar/taskbaritem.cpp
src/update/updater.cpp
src/appinfo.cpp
src/aura.cpp
src/configurationbase.cpp
src/interprocesscommunicator.cpp
src/systemdirectories.cpp
src/userdirectories.cpp
src/version.cpp)
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION})
"src/filesystem/filesystemchangedeventargs.cpp"
"src/filesystem/filesystemwatcher.cpp"
"src/helpers/stringhelpers.cpp"
"src/helpers/webhelpers.cpp"
"src/keyring/credential.cpp"
"src/keyring/keyring.cpp"
"src/keyring/keyringdialogcontroller.cpp"
"src/keyring/passwordgenerator.cpp"
"src/keyring/passwordstrength.cpp"
"src/keyring/store.cpp"
"src/keyring/systemcredentials.cpp"
"src/localization/documentation.cpp"
"src/localization/gettext.cpp"
"src/network/networkmonitor.cpp"
"src/network/networkstatechangedeventargs.cpp"
"src/notifications/notificationsenteventargs.cpp"
"src/notifications/notifyicon.cpp"
"src/notifications/notifyiconmenu.cpp"
"src/notifications/shellnotification.cpp"
"src/notifications/shellnotificationsenteventargs.cpp"
"src/taskbar/taskbaritem.cpp"
"src/update/updater.cpp"
"src/appinfo.cpp"
"src/aura.cpp"
"src/configurationbase.cpp"
"src/interprocesscommunicator.cpp"
"src/sqlite3.c"
"src/systemdirectories.cpp"
"src/userdirectories.cpp"
"src/version.cpp")
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION}")
set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "${PROJECT_VERSION}")
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic)
endif()

#libaura Packages
find_package(Boost COMPONENTS locale REQUIRED)
find_package(Boost REQUIRED COMPONENTS locale)
find_package(CURL REQUIRED)
find_package(jsoncpp REQUIRED)
find_package(Intl REQUIRED)
find_package(maddy REQUIRED)
find_package(sqlcipher REQUIRED CONFIG)
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::locale CURL::libcurl JsonCpp::JsonCpp Intl::Intl maddy::maddy sqlcipher::sqlcipher)
find_package(OpenSSL REQUIRED)
find_package(unofficial-maddy REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::boost Boost::locale CURL::libcurl JsonCpp::JsonCpp Intl::Intl OpenSSL::SSL OpenSSL::Crypto unofficial::maddy::maddy)
if(LINUX)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(libsecret REQUIRED CONFIG)
find_package(libuuid REQUIRED CONFIG)
find_package(PkgConfig REQUIRED)
pkg_check_modules(glib-2.0 REQUIRED IMPORTED_TARGET glib-2.0)
pkg_check_modules(gio-2.0 REQUIRED IMPORTED_TARGET gio-2.0)
pkg_check_modules(gmodule-2.0 REQUIRED IMPORTED_TARGET gmodule-2.0)
pkg_check_modules(gobject-2.0 REQUIRED IMPORTED_TARGET gobject-2.0)
pkg_check_modules(gthread-2.0 REQUIRED IMPORTED_TARGET gthread-2.0)
target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads libsecret::libsecret libuuid::libuuid PkgConfig::glib-2.0 PkgConfig::gio-2.0 PkgConfig::gmodule-2.0 PkgConfig::gobject-2.0 PkgConfig::gthread-2.0)
endif()
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic)
pkg_check_modules(glib REQUIRED IMPORTED_TARGET glib-2.0)
pkg_check_modules(gio REQUIRED IMPORTED_TARGET gio-2.0)
pkg_check_modules(gmodule REQUIRED IMPORTED_TARGET gmodule-2.0)
pkg_check_modules(gobject REQUIRED IMPORTED_TARGET gobject-2.0)
pkg_check_modules(gthread REQUIRED IMPORTED_TARGET gthread-2.0)
pkg_check_modules(libsecret REQUIRED IMPORTED_TARGET libsecret-1)
find_package(unofficial-libuuid CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads PkgConfig::glib PkgConfig::gio PkgConfig::gmodule PkgConfig::gobject PkgConfig::gthread PkgConfig::libsecret unofficial::UUID::uuid)
endif()

#libaura Install
configure_file("${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}.pc.in" "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}.pc" @ONLY)
configure_package_config_file("${CMAKE_SOURCE_DIR}/cmake/config.cmake.in" "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake" INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file("${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake" VERSION "${PROJECT_VERSION}" COMPATIBILITY AnyNewerVersion)
install(TARGETS ${PROJECT_NAME} EXPORT "${PROJECT_NAME}Targets" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}")
install(FILES "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}.pc" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig")
install(EXPORT "${PROJECT_NAME}Targets" FILE "${PROJECT_NAME}Targets.cmake" NAMESPACE ${PROJECT_NAME}:: DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
install(FILES "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake" "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
export(EXPORT "${PROJECT_NAME}Targets" FILE "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}Targets.cmake" NAMESPACE ${PROJECT_NAME}::)

#libaura Test
if (NOT BUILD_TESTING STREQUAL OFF)
#libaura_test Setup
add_executable(${PROJECT_NAME}_test
tests/auratests.cpp
tests/eventtests.cpp
tests/filewatchertests.cpp
tests/ipctests.cpp
tests/keyringtests.cpp
tests/main.cpp
tests/networktests.cpp
tests/notifyicontests.cpp
tests/passwordtests.cpp
tests/storetests.cpp
tests/stringtests.cpp
tests/systemcredentialstests.cpp
tests/taskbartests.cpp
tests/updatertests.cpp
tests/versiontests.cpp
tests/webtests.cpp)

#libaura_test Packages
"tests/auratests.cpp"
"tests/eventtests.cpp"
"tests/filewatchertests.cpp"
"tests/ipctests.cpp"
"tests/keyringtests.cpp"
"tests/main.cpp"
"tests/networktests.cpp"
"tests/notifyicontests.cpp"
"tests/passwordtests.cpp"
"tests/storetests.cpp"
"tests/stringtests.cpp"
"tests/systemcredentialstests.cpp"
"tests/taskbartests.cpp"
"tests/updatertests.cpp"
"tests/versiontests.cpp"
"tests/webtests.cpp")
find_package(GTest REQUIRED)
target_link_libraries(${PROJECT_NAME}_test PRIVATE GTest::gtest_main GTest::gmock_main libaura)
endif()

#libaura Install
configure_file(${PROJECT_SOURCE_DIR}/pkg-config/libaura.pc.in libaura.pc @ONLY)
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
install(FILES ${CMAKE_BINARY_DIR}/libaura.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
target_link_libraries(${PROJECT_NAME}_test PRIVATE GTest::gtest_main GTest::gmock_main ${PROJECT_NAME})
endif()
41 changes: 41 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": 3,
"configurePresets": [
{
"name": "windows-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "x64-debug",
"displayName": "x64 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-release",
"displayName": "x64 Release",
"inherits": "x64-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
]
}
Loading

0 comments on commit 7693072

Please sign in to comment.