diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 6cb2227..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.vscode -build/* diff --git a/CMakeLists.txt b/CMakeLists.txt index 0903cc5..b2f07dc 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,10 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.3) project(lunasvg VERSION 2.3.5 LANGUAGES CXX C) set(CMAKE_CXX_STANDARD 17) set(CMAKE_C_STANDARD 11) -# Default to hidden visibility for symbols -set(CMAKE_C_VISIBILITY_PRESET hidden) -set(CMAKE_CXX_VISIBILITY_PRESET hidden) -set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) - option(BUILD_SHARED_LIBS "Builds as shared library" OFF) option(LUNASVG_BUILD_EXAMPLES "Builds examples" OFF) @@ -19,61 +14,25 @@ add_subdirectory(include) add_subdirectory(source) add_subdirectory(3rdparty/plutovg) -set_target_properties(lunasvg - PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" -) - -add_library(lunasvg::lunasvg ALIAS lunasvg) - -if(NOT BUILD_SHARED_LIBS) - target_compile_definitions(lunasvg PUBLIC LUNASVG_STATIC_DEFINE) +if(BUILD_SHARED_LIBS) + target_compile_definitions(lunasvg PUBLIC LUNASVG_SHARED) + target_compile_definitions(lunasvg PRIVATE LUNASVG_EXPORT) endif() if(LUNASVG_BUILD_EXAMPLES) add_subdirectory(example) endif() -# -# Installation -# -include(GNUInstallDirs) -install( - FILES - ${CMAKE_CURRENT_SOURCE_DIR}/include/lunasvg.h - ${CMAKE_CURRENT_BINARY_DIR}/include/lunasvg_export.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lunasvg -) -install( - TARGETS lunasvg - EXPORT lunasvg-targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) -install( - EXPORT lunasvg-targets - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/lunasvg NAMESPACE lunasvg:: FILE lunasvgTargets.cmake -) - -include(CMakePackageConfigHelpers) -configure_package_config_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lunasvgConfig.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/lunasvgConfig.cmake - INSTALL_DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/lunasvg -) - -write_basic_package_version_file(lunasvgConfigVersion.cmake - VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion -) +set(LUNASVG_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib) +set(LUNASVG_INCDIR ${CMAKE_INSTALL_PREFIX}/include) install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/lunasvgConfig.cmake - ${CMAKE_CURRENT_BINARY_DIR}/lunasvgConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/lunasvg + include/lunasvg.h + DESTINATION ${LUNASVG_INCDIR} ) -export(EXPORT lunasvg-targets FILE ${CMAKE_CURRENT_BINARY_DIR}/lunasvgTargets.cmake NAMESPACE lunasvg::) +install(TARGETS lunasvg + LIBRARY DESTINATION ${LUNASVG_LIBDIR} + ARCHIVE DESTINATION ${LUNASVG_LIBDIR} + INCLUDES DESTINATION ${LUNASVG_INCDIR} +) diff --git a/cmake/lunasvgConfig.cmake.in b/cmake/lunasvgConfig.cmake.in deleted file mode 100644 index 850098f..0000000 --- a/cmake/lunasvgConfig.cmake.in +++ /dev/null @@ -1,3 +0,0 @@ -@PACKAGE_INIT@ - -include("${CMAKE_CURRENT_LIST_DIR}/lunasvgTargets.cmake") diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index de18b31..53ec5ef 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.3) set(CMAKE_CXX_STANDARD 14) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 70d896f..de58954 100755 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,16 +1,4 @@ -# Generate a standard header with export macros -include(GenerateExportHeader) -generate_export_header(lunasvg) - target_include_directories(lunasvg - # When building a project that uses the lunasvg library, - # we need to look in the installed include directory - PUBLIC - $ - - # When building the lunasvg library we need to look in the - # build dir for the lunasvg_export.h header and in the source - # dir for other headers - $ - $ +PUBLIC + "${CMAKE_CURRENT_LIST_DIR}" ) diff --git a/include/lunasvg.h b/include/lunasvg.h index 687b572..d19325c 100644 --- a/include/lunasvg.h +++ b/include/lunasvg.h @@ -27,8 +27,15 @@ #include #include -#include -#define LUNASVG_API LUNASVG_EXPORT +#if defined(_MSC_VER) && defined(LUNASVG_SHARED) +#ifdef LUNASVG_EXPORT +#define LUNASVG_API __declspec(dllexport) +#else +#define LUNASVG_API __declspec(dllimport) +#endif +#else +#define LUNASVG_API +#endif namespace lunasvg {