diff --git a/CMakeLists.txt b/CMakeLists.txt index 24d91b50..4ffaf764 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,7 +178,7 @@ endif () configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/version.h.ini - ${CMAKE_BINARY_DIR}/Version.h + ${CMAKE_BINARY_DIR}/version.h @ONLY ) diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index 3198f6db..f3e55da9 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -1,30 +1,36 @@ include_directories(include source) - +include(GenerateExportHeader) file(GLOB api_src_list include/*.h source/*.cpp source/*.h source/*.c) if (IOS) add_library(mk_api STATIC ${api_src_list}) target_link_libraries(mk_api ${LINK_LIB_LIST} jsoncpp) else () - if(ENABLE_API_STATIC_LIB) + if (ENABLE_API_STATIC_LIB) add_library(mk_api STATIC ${api_src_list}) - if (WIN32) - add_definitions(-DMediaKitApi_STATIC) - endif () else () add_library(mk_api SHARED ${api_src_list}) - if (WIN32) - add_definitions(-DMediaKitApi_EXPORTS) - endif () - endif() + endif () + if (CMAKE_SYSTEM_NAME MATCHES "Linux") target_link_libraries(mk_api -Wl,--start-group jsoncpp ${LINK_LIB_LIST} -Wl,--end-group) else () target_link_libraries(mk_api jsoncpp ${LINK_LIB_LIST}) endif () add_subdirectory(tests) +endif () - file(GLOB api_header_list include/*.h) +add_definitions(-DGENERATE_EXPORT) +include_directories(${CMAKE_BINARY_DIR}) +generate_export_header(mk_api + EXPORT_MACRO_NAME API_EXPORT + BASE_NAME MK_API + STATIC_DEFINE MediaKitApi_STATIC + EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/mk_export.h" + ) + +if (NOT IOS) + file(GLOB api_header_list include/*.h ${CMAKE_BINARY_DIR}/*.h) install(FILES ${api_header_list} DESTINATION ${INSTALL_PATH_INCLUDE}) install(TARGETS mk_api ARCHIVE DESTINATION ${INSTALL_PATH_LIB} LIBRARY DESTINATION ${INSTALL_PATH_LIB}) -endif () +endif () \ No newline at end of file diff --git a/api/include/mk_common.h b/api/include/mk_common.h index 63835410..7105f0d3 100755 --- a/api/include/mk_common.h +++ b/api/include/mk_common.h @@ -14,21 +14,26 @@ #include #include +#if defined(GENERATE_EXPORT) +#include "mk_export.h" +#endif + #if defined(_WIN32) && defined(_MSC_VER) -# ifndef MediaKitApi_STATIC -# if defined(MediaKitApi_EXPORTS) -# define API_EXPORT __declspec(dllexport) -# else -# define API_EXPORT __declspec(dllimport) -# endif -# define API_CALL __cdecl -# else -# define API_EXPORT -# define API_CALL -# endif +# define API_CALL __cdecl #else +# define API_CALL +#endif + +#if defined(_WIN32) && defined(_MSC_VER) +# if !defined(GENERATE_EXPORT) +# if defined(MediaKitApi_EXPORTS) +# define API_EXPORT __declspec(dllexport) +# else +# define API_EXPORT __declspec(dllimport) +# endif +# endif +#elif !defined(GENERATE_EXPORT) # define API_EXPORT -# define API_CALL #endif #ifdef __cplusplus diff --git a/api/source/mk_frame.cpp b/api/source/mk_frame.cpp index 55771afa..0bd973e2 100644 --- a/api/source/mk_frame.cpp +++ b/api/source/mk_frame.cpp @@ -17,7 +17,7 @@ using namespace mediakit; extern "C" { -#define XX(name, type, value, str, mpeg_id) const int MK##name = value; +#define XX(name, type, value, str, mpeg_id) API_EXPORT const int MK##name = value; CODEC_MAP(XX) #undef XX } diff --git a/api/tests/CMakeLists.txt b/api/tests/CMakeLists.txt index e3ecd64b..21a2fb6e 100644 --- a/api/tests/CMakeLists.txt +++ b/api/tests/CMakeLists.txt @@ -1,4 +1,6 @@ aux_source_directory(. TEST_SRC_LIST) +include_directories(${PROJECT_BINARY_DIR}/api) + foreach(TEST_SRC ${TEST_SRC_LIST}) STRING(REGEX REPLACE "^\\./|\\.c[a-zA-Z0-9_]*$" "" TEST_EXE_NAME ${TEST_SRC}) diff --git a/server/main.cpp b/server/main.cpp index b672995f..f2dd1f61 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -33,7 +33,7 @@ #endif #if defined(ENABLE_VERSION) -#include "Version.h" +#include "version.h" #endif #if !defined(_WIN32) diff --git a/src/Common/macros.cpp b/src/Common/macros.cpp index 6c9d1302..e6a43699 100644 --- a/src/Common/macros.cpp +++ b/src/Common/macros.cpp @@ -14,7 +14,7 @@ using namespace toolkit; #if defined(ENABLE_VERSION) -#include "Version.h" +#include "version.h" #endif extern "C" {