Browse Source

Use static library for aptdec executable, to avoid having to set path to library

tags/v1.8.0
Jon Beniston 3 years ago
parent
commit
fb6fb49929
2 changed files with 13 additions and 3 deletions
  1. +7
    -3
      CMakeLists.txt
  2. +6
    -0
      src/apt.h

+ 7
- 3
CMakeLists.txt View File

@@ -13,6 +13,9 @@ set(LIB_C_SOURCE_FILES src/color.c src/dsp.c src/filter.c src/image.c src/libs/r
set(EXE_C_SOURCE_FILES src/main.c src/pngio.c src/libs/argparse.c) set(EXE_C_SOURCE_FILES src/main.c src/pngio.c src/libs/argparse.c)
set(LIB_C_HEADER_FILES src/apt.h) set(LIB_C_HEADER_FILES src/apt.h)


# Link with static library for aptdec executable, so we don't need to set the path
add_library(libaptdecstatic STATIC ${LIB_C_SOURCE_FILES})
# Create shared library for 3rd party apps
add_library(libaptdec SHARED ${LIB_C_SOURCE_FILES}) add_library(libaptdec SHARED ${LIB_C_SOURCE_FILES})


add_compile_definitions(PALETTE_DIR="../palettes") add_compile_definitions(PALETTE_DIR="../palettes")
@@ -23,9 +26,9 @@ if (PNG_FOUND AND LIBSNDFILE_FOUND)
include_directories(${LIBSNDFILE_INCLUDE_DIR}) include_directories(${LIBSNDFILE_INCLUDE_DIR})
target_link_libraries(aptdec PRIVATE PNG::PNG) target_link_libraries(aptdec PRIVATE PNG::PNG)
target_link_libraries(aptdec PRIVATE ${LIBSNDFILE_LIBRARY}) target_link_libraries(aptdec PRIVATE ${LIBSNDFILE_LIBRARY})
target_link_libraries(aptdec PRIVATE libaptdec)
target_link_libraries(aptdec PRIVATE libaptdecstatic)
if (MSVC) if (MSVC)
target_compile_options(aptdec PRIVATE /D_CRT_SECURE_NO_WARNINGS=1)
target_compile_options(aptdec PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPT_API_STATIC)
else() else()
# Math # Math
target_link_libraries(aptdec PRIVATE m) target_link_libraries(aptdec PRIVATE m)
@@ -42,10 +45,11 @@ else()
endif() endif()


if (MSVC) if (MSVC)
target_compile_options(libaptdec PRIVATE /D_CRT_SECURE_NO_WARNINGS=1)
target_compile_options(libaptdec PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPT_API_EXPORT)
else() else()
# Math # Math
target_link_libraries(libaptdec PRIVATE m) target_link_libraries(libaptdec PRIVATE m)
target_link_libraries(libaptdecstatic PRIVATE m)


if(CMAKE_BUILD_TYPE MATCHES "Release") if(CMAKE_BUILD_TYPE MATCHES "Release")
target_compile_options(libaptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers -Werror) target_compile_options(libaptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers -Werror)


+ 6
- 0
src/apt.h View File

@@ -24,7 +24,13 @@
#if defined (__GNUC__) && (__GNUC__ >= 4) #if defined (__GNUC__) && (__GNUC__ >= 4)
#define APT_API __attribute__((visibility("default"))) #define APT_API __attribute__((visibility("default")))
#elif defined (_MSC_VER) #elif defined (_MSC_VER)
#ifdef APT_API_EXPORT
#define APT_API __declspec(dllexport) #define APT_API __declspec(dllexport)
#elif APT_API_STATIC
#define APT_API
#else if
#define APT_API __declspec(dllimport)
#endif
#else #else
#define APT_API #define APT_API
#endif #endif


Loading…
Cancel
Save