Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project(libdigidocpp VERSION 4.4.0
DESCRIPTION "C++ library for digital signatures and validation of digitally signed documents"
HOMEPAGE_URL https://github.com/open-eid/libdigidocpp
)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})

macro(SET_ENV NAME DEF)
Expand All @@ -24,12 +24,12 @@ include(GNUInstallDirs)

set_env( TSL_URL "https://ec.europa.eu/tools/lotl/eu-lotl.xml" CACHE STRING "TSL trust list primary URL" )
set_env( TSL_CERTS
${CMAKE_SOURCE_DIR}/etc/tl-mp1.crt
${CMAKE_SOURCE_DIR}/etc/tl-mp2.crt
${CMAKE_SOURCE_DIR}/etc/tl-mp3.crt
${CMAKE_SOURCE_DIR}/etc/tl-mp4.crt
${CMAKE_SOURCE_DIR}/etc/tl-mp5.crt
${CMAKE_SOURCE_DIR}/etc/tl-mp6.crt
${PROJECT_SOURCE_DIR}/etc/tl-mp1.crt
${PROJECT_SOURCE_DIR}/etc/tl-mp2.crt
${PROJECT_SOURCE_DIR}/etc/tl-mp3.crt
${PROJECT_SOURCE_DIR}/etc/tl-mp4.crt
${PROJECT_SOURCE_DIR}/etc/tl-mp5.crt
${PROJECT_SOURCE_DIR}/etc/tl-mp6.crt
CACHE FILEPATH "TSL trust list signing certificates" )
set_env(TSA_URL "https://eid-dd.ria.ee/ts" CACHE STRING "Default TSA URL")
set_env( SIVA_URL "https://siva.eesti.ee/V3/validate" CACHE STRING "Default SiVa validation service URL" )
Expand Down Expand Up @@ -92,13 +92,13 @@ endif()

find_package(Doxygen)
if(TARGET Doxygen::doxygen)
configure_file( ${CMAKE_SOURCE_DIR}/etc/Doxyfile.in Doxyfile @ONLY )
configure_file(${PROJECT_SOURCE_DIR}/etc/Doxyfile.in Doxyfile @ONLY)
add_custom_target( docs ALL
Doxygen::doxygen Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
install( DIRECTORY ${CMAKE_BINARY_DIR}/doc/ DESTINATION ${CMAKE_INSTALL_DOCDIR} )
install(DIRECTORY ${PROJECT_BINARY_DIR}/doc/ DESTINATION ${CMAKE_INSTALL_DOCDIR})
install( DIRECTORY doc/ DESTINATION ${CMAKE_INSTALL_DOCDIR} )
endif()

Expand Down
16 changes: 8 additions & 8 deletions etc/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ PROJECT_BRIEF =
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
# the logo to the output directory.

PROJECT_LOGO = @CMAKE_SOURCE_DIR@/ID.ico
PROJECT_LOGO = @PROJECT_SOURCE_DIR@/ID.ico

# With the PROJECT_ICON tag one can specify an icon that is included in the tabs
# when the HTML document is shown. Doxygen will copy the logo to the output
Expand All @@ -74,7 +74,7 @@ PROJECT_ICON =
# entered, it will be relative to the location where Doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = @CMAKE_BINARY_DIR@/doc/
OUTPUT_DIRECTORY = @PROJECT_BINARY_DIR@/doc/

# If the CREATE_SUBDIRS tag is set to YES then Doxygen will create up to 4096
# sub-directories (in 2 levels) under the output directory of each output format
Expand Down Expand Up @@ -965,8 +965,8 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = @CMAKE_SOURCE_DIR@/src \
@CMAKE_SOURCE_DIR@/libdigidocpp.dox
INPUT = @PROJECT_SOURCE_DIR@/src \
@PROJECT_SOURCE_DIR@/libdigidocpp.dox

# This tag can be used to specify the character encoding of the source files
# that Doxygen parses. Internally Doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down Expand Up @@ -1076,8 +1076,8 @@ EXCLUDE_SYMBOLS = digidoc::*Private \
# that contain example code fragments that are included (see the \include
# command).

EXAMPLE_PATH = @CMAKE_SOURCE_DIR@/ \
@CMAKE_BINARY_DIR@/
EXAMPLE_PATH = @PROJECT_SOURCE_DIR@/ \
@PROJECT_BINARY_DIR@/

# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
Expand All @@ -1097,7 +1097,7 @@ EXAMPLE_RECURSIVE = NO
# that contain images that are to be included in the documentation (see the
# \image command).

IMAGE_PATH = @CMAKE_SOURCE_DIR@/doc/images/
IMAGE_PATH = @PROJECT_SOURCE_DIR@/doc/images/

# The INPUT_FILTER tag can be used to specify a program that Doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
Expand Down Expand Up @@ -1358,7 +1358,7 @@ HTML_STYLESHEET =
# documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.

HTML_EXTRA_STYLESHEET = @CMAKE_SOURCE_DIR@/etc/Doxyfile.css
HTML_EXTRA_STYLESHEET = @PROJECT_SOURCE_DIR@/etc/Doxyfile.css

# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
Expand Down
1 change: 0 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
include_directories( ${CMAKE_SOURCE_DIR}/src )
add_executable( pkcs11sign pkcs11sign.cpp )
set_target_properties( pkcs11sign PROPERTIES
LINK_LIBRARIES digidocpp
Expand Down
2 changes: 1 addition & 1 deletion prepare_osx_build_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function xmlsec {
rm -rf ${XMLSEC_DIR}
tar xf ${XMLSEC_DIR}.tar.gz
cd ${XMLSEC_DIR}
patch -Np1 -i ../vcpkg-ports/xmlsec/xmlsec1-1.3.5.legacy.patch
patch -Np1 -i ../xmlsec1-1.3.5.legacy.patch
case "${ARGS}" in
*iphone*) CONFIGURE="--host=aarch64-apple-darwin --enable-static --disable-shared --without-libxslt" ;;
*) CONFIGURE="--disable-static --enable-shared" ;;
Expand Down
59 changes: 34 additions & 25 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set_env(BUILD_NUMBER 0)
set(VERSION ${PROJECT_VERSION}.${BUILD_NUMBER})

configure_file( libdigidocpp.pc.cmake libdigidocpp.pc @ONLY )
configure_file( ${CMAKE_SOURCE_DIR}/etc/digidocpp.conf.cmake digidocpp.conf )
configure_file(${PROJECT_SOURCE_DIR}/etc/digidocpp.conf.cmake digidocpp.conf)

file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tslcerts.h "namespace digidoc {\nstatic const std::vector<X509Cert> tslcerts {\n")
foreach(TSL_CERT ${TSL_CERTS})
Expand All @@ -23,7 +23,7 @@ foreach(TSL_CERT ${TSL_CERTS})
endforeach()
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/tslcerts.h "};\n}")

set(SCHEMA_DIR ${CMAKE_SOURCE_DIR}/etc/schema)
set(SCHEMA_DIR ${PROJECT_SOURCE_DIR}/etc/schema)
set( SCHEMA_FILES
${SCHEMA_DIR}/conf.xsd
${SCHEMA_DIR}/OpenDocument_manifest_v1_2.xsd
Expand Down Expand Up @@ -66,7 +66,10 @@ add_library(digidocpp_util STATIC
util/log.cpp
)

target_link_libraries(digidocpp_util PUBLIC digidocpp_ver PRIVATE $<$<OR:$<PLATFORM_ID:Darwin>,$<PLATFORM_ID:iOS>>:-framework\ CoreFoundation>)
target_link_libraries(digidocpp_util
PUBLIC $<BUILD_INTERFACE:digidocpp_ver>
PRIVATE $<$<OR:$<PLATFORM_ID:Darwin>,$<PLATFORM_ID:iOS>>:-framework\ CoreFoundation>
)

add_library(digidocpp_tsl STATIC
crypto/Connect.cpp
Expand All @@ -82,7 +85,7 @@ set_target_properties(digidocpp_util digidocpp_tsl PROPERTIES
POSITION_INDEPENDENT_CODE YES
)

target_include_directories(digidocpp_tsl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(digidocpp_tsl PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

target_link_libraries(digidocpp_tsl
digidocpp_util
Expand Down Expand Up @@ -252,7 +255,11 @@ if(SWIG_FOUND)
endif()
endif()

install( TARGETS digidocpp
if(NOT ${BUILD_SHARED_LIBS})
set(STATIC_TARGETS minizip digidocpp_tsl digidocpp_util)
endif()

install(TARGETS digidocpp ${STATIC_TARGETS}
EXPORT libdigidocppExport
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand All @@ -261,29 +268,31 @@ install( TARGETS digidocpp
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/digidocpp
FRAMEWORK DESTINATION ${FRAMEWORK_DESTINATION}
)
if(NOT ANDROID)
install(EXPORT libdigidocppExport
FILE libdigidocpp-config.cmake
NAMESPACE digidocpp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libdigidocpp
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/libdigidocpp-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libdigidocpp-config-version.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libdigidocpp
)
endif()

install(EXPORT libdigidocppExport
FILE libdigidocpp-config.cmake
NAMESPACE digidocpp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libdigidocpp
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/libdigidocpp-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libdigidocpp-config-version.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libdigidocpp
)

if(WIN32)
list(APPEND CRYPTO_HEADER crypto/WinSigner.h)
target_compile_options(digidocpp_util PUBLIC "/guard:cf")
target_link_options(digidocpp PUBLIC "/guard:cf")
target_link_libraries(digidocpp PRIVATE Crypt32 cryptui ncrypt)
install(FILES $<TARGET_PDB_FILE:digidocpp> $<TARGET_PDB_FILE:digidoc-tool> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
install(FILES $<TARGET_PDB_FILE:digidocpp> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
if(TARGET digidoc-tool)
install(FILES $<TARGET_PDB_FILE:digidoc-tool> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
endif()
if(SIGNCERT)
foreach(TARGET digidocpp digidoc-tool digidoc_java digidoc_csharp digidoc_python)
if (TARGET ${TARGET})
Expand All @@ -310,7 +319,7 @@ if( FRAMEWORK )
set_source_files_properties( ${CRYPTO_HEADER} PROPERTIES MACOSX_PACKAGE_LOCATION Headers/crypto )
list(GET OPENSSL_LIBRARIES 0 LIBPATH)
get_filename_component( LIBPATH ${LIBPATH} PATH )
set(COPY_LIBRARIES_SCRIPT ${CMAKE_BINARY_DIR}/copy_libraries.cmake)
set(COPY_LIBRARIES_SCRIPT ${PROJECT_BINARY_DIR}/copy_libraries.cmake)
file(WRITE ${COPY_LIBRARIES_SCRIPT} "
message(\"Copy dependencies: \$ENV{LIBRARY} \$ENV{BUNDLE_DIR}\")
file(GET_RUNTIME_DEPENDENCIES LIBRARIES \$ENV{LIBRARY} RESOLVED_DEPENDENCIES_VAR OUT)
Expand Down Expand Up @@ -372,13 +381,13 @@ if( FRAMEWORK )
add_custom_target(pkgbuild DEPENDS digidocpp $<TARGET_NAME_IF_EXISTS:digidoc-tool>
COMMAND DESTDIR=install ${CMAKE_COMMAND} --install .
COMMAND pkgbuild --root install "$<$<BOOL:${SIGNCERT}>:--sign;${SIGNCERT}>"
${CMAKE_BINARY_DIR}/libdigidocpp_${VERSION}$ENV{VER_SUFFIX}.pkg
${PROJECT_BINARY_DIR}/libdigidocpp_${VERSION}$ENV{VER_SUFFIX}.pkg
COMMAND_EXPAND_LISTS
)
add_custom_target(zipdebug DEPENDS digidocpp $<TARGET_NAME_IF_EXISTS:digidoc-tool>
COMMAND dsymutil -o libdigidocpp.dSYM $<TARGET_FILE:digidocpp>
$<$<TARGET_EXISTS:digidoc-tool>:$<TARGET_FILE:digidoc-tool>>
COMMAND zip -r ${CMAKE_BINARY_DIR}/libdigidocpp-dbg_${VERSION}$ENV{VER_SUFFIX}.zip libdigidocpp.dSYM
COMMAND zip -r ${PROJECT_BINARY_DIR}/libdigidocpp-dbg_${VERSION}$ENV{VER_SUFFIX}.zip libdigidocpp.dSYM
)
else()
if(NOT ${BUILD_SHARED_LIBS})
Expand Down
1 change: 1 addition & 0 deletions src/XMLDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ struct XMLDocument: public unique_free_d<xmlFreeDoc>, public XMLNode
auto result = xmlParseDocument(ctxt.get());
if(result != 0 || !ctxt->wellFormed)
{
xmlFreeDoc(ctxt->myDoc);
if(const xmlError *lastError = xmlCtxtGetLastError(ctxt.get()))
THROW("%s", lastError->message);
THROW("Failed to parse XML document from stream");
Expand Down
8 changes: 4 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set_env(TEST_FORMAT XML CACHE STRING "Test result format (XML/JUNIT)")
set( CMAKE_SKIP_RPATH OFF )
add_definitions(
-DDIGIDOCPPCONF="${CMAKE_SOURCE_DIR}/etc/schema"
-DDIGIDOCPPCONF="${PROJECT_SOURCE_DIR}/etc/schema"
-DPKCS11_MODULE="${PKCS11_MODULE}"
-DSIVA_URL="${SIVA_URL}"
)
Expand All @@ -15,7 +15,7 @@ if(WIN32)
endif()
add_test(NAME runtest
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/unittests --build_info=YES --report_level=no --logger=${TEST_FORMAT},all,${CMAKE_CURRENT_BINARY_DIR}/libdigidocpp.xml -- ${CMAKE_CURRENT_SOURCE_DIR}/data
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/src
)

# Bad status tests
Expand All @@ -26,7 +26,7 @@ foreach(TEST CA-non-qa no_QCStatement no_QCSD
)
add_test(NAME TSLTest_${TEST}
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/TSLTests -- EE_T-${TEST}.xml bad ${CMAKE_CURRENT_SOURCE_DIR}/data
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/src
)
endforeach()

Expand All @@ -37,7 +37,7 @@ foreach(TEST CA-withdrawn-granted-before CA-noqscd-granted-before
)
add_test(NAME TSLTest_${TEST}
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/TSLTests -- EE_T-${TEST}.xml good ${CMAKE_CURRENT_SOURCE_DIR}/data
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/src
)
endforeach()

Expand Down
Loading