Skip to content

Commit

Permalink
Add Conan Package Info
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed Jan 2, 2024
1 parent 51c18dd commit 68689f2
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 13 deletions.
21 changes: 11 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ endif()

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

#libaura Library Setup
include_directories(${PROJECT_SOURCE_DIR}/include)
Expand Down Expand Up @@ -79,15 +80,9 @@ else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic)
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)

#libaura_test
if(NOT SKIP_TESTS)
#libaura_test Setup
#libaura Test
if (NOT BUILD_TESTING STREQUAL OFF)
#libaura_test Setup
add_executable(${PROJECT_NAME}_test
tests/auratests.cpp
tests/eventtests.cpp
Expand All @@ -109,4 +104,10 @@ if(NOT SKIP_TESTS)
#libaura_test Packages
find_package(GTest REQUIRED)
target_link_libraries(${PROJECT_NAME}_test PUBLIC libaura GTest::gtest_main GTest::gmock_main)
endif()
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)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Visual Studio 2022 with C++ Desktop workload is required to be installed.
1. Run `conan install conanfile-windows.txt --profile:host=conanprofile-windows.txt --profile:build=conanprofile-windows.txt -s compiler.cppstd=20 --build=missing`.
1. Once that command finishes, cd into the `build` folder.
1. From the `build` folder, run `cmake .. -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake"`.
- To skip building libaura's test suite, add `-DSKIP_TESTS="true"` to the end of the command.
- To skip building libaura's test suite, add `-DBUILD_TESTING="Off"` to the end of the command.
1. From the `build` folder, run ``cmake --build . --config Release`.
1. After these commands, libaura will be successfully built and its binaries can be found in the `Release` folder of the `build` folder.
1. To install libaura to the system, from the `build` folder, run `cmake --install . --prefix "PATH_TO_INSTALL_DIR"`.
Expand All @@ -44,7 +44,7 @@ Visual Studio 2022 with C++ Desktop workload is required to be installed.
1. Run `conan install conanfile-linux.txt --profile:host=conanprofile-linux.txt --profile:build=conanprofile-linux.txt -s compiler.cppstd=20 --build=missing`.
1. Once that command finished, cd into the `build` folder.
1. From the `build` folder, run `cmake .. -DCMAKE_TOOLCHAIN_FILE="Release/generators/conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Release`.
- To skip building libaura's test suite, add `-DSKIP_TESTS="true"` to the end of the command.
- To skip building libaura's test suite, add `-DBUILD_TESTING="Off"` to the end of the command.
1. From the `build` folder, run `cmake --build`.
1. After these commands, libaura will be successfully built and its binaries can be found in the `Release` folder of the `build` folder.
1. To install libaura to the system, from the `build` folder, run `cmake --install . --prefix "PATH_TO_INSTALL_DIR"`.
Expand Down
79 changes: 79 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
from conan.tools.scm import Git
from conan.tools.build import check_min_cppstd

class libauraRecipe(ConanFile):
name = "libaura"
version = "2024.1.0"
package_type = "library"

# Optional metadata
license = "GPLv3"
author = "Nicholas Logozzo [email protected]"
url = "https://github.com/NickvisionApps/libaura"
description = "A cross-platform base for native Nickvision applications."
topics = ("framework", "desktop", "gtk", "winui")

# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

def validate(self):
check_min_cppstd(self, "20")

def requirements(self):
self.requires("boost/1.83.0")
self.test_requires("gtest/1.14.00")
self.requires("jsoncpp/1.9.5")
self.requires("libcurl/8.4.0")
self.requires("libgettext/0.22")
self.requires("maddy/1.3.0")
self.requires("sqlcipher/4.5.1")
if self.settings.os == "Linux":
self.requires("glib/2.78.1")
self.requires("libsecret/0.20.5")
self.requires("libuuid/1.0.3")

def source(self):
git = Git(self)
git.clone(url="https://github.com/NickvisionApps/libaura.git", target=".")
git.checkout("2024.1.0-pre")

def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")
else:
self.settings.os.libc = "glibc"
self.settings.os.libc.version = "2.35"

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def layout(self):
cmake_layout(self)

def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
if not self.conf.get("tools.build:skip_test", default=False):
test_folder = os.path
if self.settings.os == "Windows":
test_folder = os.path.join("", str(self.settings.build_type))
self.run(os.path.join(test_folder, "libaura_test"))

def package(self):
cmake = CMake(self)
cmake.install()

def package_info(self):
self.cpp_info.libs = ["libaura"]
2 changes: 1 addition & 1 deletion include/aura.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Nickvision::Aura
* @return The config object
*/
template<DerivedConfigurationBase T>
T& getConfig(const std::string& key) noexcept
T& getConfig(const std::string& key)
{
if (key.empty())
{
Expand Down
7 changes: 7 additions & 0 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.15)
project(PackageTest CXX)

find_package(libaura CONFIG REQUIRED)

add_executable(example src/example.cpp)
target_link_libraries(example libaura::libaura)
25 changes: 25 additions & 0 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os

from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run

class libauraTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def layout(self):
cmake_layout(self)

def test(self):
if can_run(self):
cmd = os.path.join(self.cpp.build.bindir, "example")
self.run(cmd, env="conanrun")
8 changes: 8 additions & 0 deletions test_package/src/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "aura.h"

int main()
{
Aura::init("io.conan.aura.test", "Conan Aura Test", "Test");
std::cout << Aura::getActive().getAppInfo().getName() << std::endl;
return 0;
}

0 comments on commit 68689f2

Please sign in to comment.