Skip to content

Commit

Permalink
vcpkg: initial files
Browse files Browse the repository at this point in the history
  • Loading branch information
igagis committed Nov 24, 2024
1 parent 09b20f7 commit 4409464
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 1 deletion.
68 changes: 68 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
cmake_minimum_required(VERSION 3.10)

include(GNUInstallDirs)

set(name mikroxml)

project(${name})

find_package(utki CONFIG REQUIRED)
find_package(papki CONFIG REQUIRED)
find_package(ZLIB REQUIRED)

file(GLOB_RECURSE srcs "../src/${name}/*.cpp")

add_library(
${name}
STATIC
${srcs}
)

target_compile_features(${name} PUBLIC cxx_std_17)
set_target_properties(${name} PROPERTIES CXX_STANDARD_REQUIRED ON)
set_target_properties(${name} PROPERTIES CXX_EXTENSIONS OFF)

target_include_directories(
${name}
INTERFACE
$<BUILD_INTERFACE:>
$<INSTALL_INTERFACE:include>
)

target_link_libraries(
${name}
PUBLIC
utki::utki
papki::papki
PRIVATE
ZLIB::ZLIB
)

# install library header files preserving directory hierarchy
install(
DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/../src/${name}"
DESTINATION
"${CMAKE_INSTALL_INCLUDEDIR}"
FILES_MATCHING PATTERN
"*.hpp"
)

install(
TARGETS
${name}
EXPORT # generate cmake configs
${name}-config
)

# install cmake configs
install(
EXPORT
${name}-config
FILE
${name}-config.cmake
DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/${name}
NAMESPACE
${name}::
)
5 changes: 4 additions & 1 deletion src/mikroxml/mikroxml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ namespace mikroxml {
class malformed_xml : public std::logic_error
{
public:
malformed_xml(unsigned line_number, const std::string& message);
malformed_xml(
unsigned line_number, //
const std::string& message
);
};

class parser
Expand Down
26 changes: 26 additions & 0 deletions vcpkg/portfile.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO cppfw/${PORT}
REF $(git_ref)
SHA512 $(archive_hash)
HEAD_REF main
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}/cmake"
)

vcpkg_cmake_install()

vcpkg_cmake_config_fixup()

# Delete the include directory from the debug installation to prevent overlap.
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

# Install the LICENSE file to the package's share directory and rename it to copyright.
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

# Copy the usage instruction file to the package's share directory.
configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" COPYONLY)
12 changes: 12 additions & 0 deletions vcpkg/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.10)

set(CMAKE_TOOLCHAIN_FILE $ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)

project(test)

find_package(utki CONFIG REQUIRED)
find_package(mikroxml CONFIG REQUIRED)

add_executable(test main.cpp)

target_link_libraries(test PRIVATE mikroxml::mikroxml)
11 changes: 11 additions & 0 deletions vcpkg/test/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <mikroxml/mikroxml.hpp>

int main(int argc, const char** argv){
try{
throw mikroxml::malformed_xml(10, "file.xml");
}catch(std::exception& e){
std::cout << "exception caught: " << e.what() << std::endl;
}

return 0;
}
19 changes: 19 additions & 0 deletions vcpkg/test/vcpkg-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"default-registry": {
"kind": "git",
"baseline": "5e5d0e1cd7785623065e77eff011afdeec1a3574",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "git",
"repository": "https://github.com/cppfw/vcpkg-repo/",
"baseline": "",
"reference": "main",
"packages": [ "utki", "papki" ]
}
],
"overlay-ports": [
"../overlay"
]
}
5 changes: 5 additions & 0 deletions vcpkg/test/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": [
"mikroxml"
]
}
4 changes: 4 additions & 0 deletions vcpkg/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mikroxml provides CMake targets:

find_package(mikroxml CONFIG REQUIRED)
target_link_libraries(main PRIVATE mikroxml::mikroxml)
18 changes: 18 additions & 0 deletions vcpkg/vcpkg.json.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "mikroxml",
"version": "$(version)",
"homepage": "https://github.com/cppfw/mikroxml",
"description": "simple stream XML parser in C++",
"license": "MIT",
"dependencies": [
{
"name" : "vcpkg-cmake",
"host" : true
},
{
"name" : "vcpkg-cmake-config",
"host" : true
},
"utki"
]
}

0 comments on commit 4409464

Please sign in to comment.