diff --git a/CMakeLists.txt b/CMakeLists.txt index c62e552..c75767d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,8 +16,8 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") ### compile option set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) if (CMAKE_CXX_STANDARD_REQUIRED) message(STATUS "Set cxx standard ${CMAKE_CXX_STANDARD}") else() diff --git a/templates/CMakeLists.txt b/templates/CMakeLists.txt index c0e3861..dfca873 100644 --- a/templates/CMakeLists.txt +++ b/templates/CMakeLists.txt @@ -12,8 +12,8 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED YES) set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_compile_options("$<$:/source-charset:utf-8>") #### deps lib @@ -26,7 +26,13 @@ add_library(${PROJECT_NAME} SHARED target_link_libraries(${PROJECT_NAME} myframe ) -target_compile_definitions(${PROJECT_NAME} PRIVATE myframe_EXPORTS) + +#### export +include (GenerateExportHeader) +generate_export_header (${PROJECT_NAME} + EXPORT_MACRO_NAME MYFRAME_SUBMODULE_EXPORT + EXPORT_FILE_NAME "${CMAKE_CURRENT_SOURCE_DIR}/export.h" +) #### install install(TARGETS ${PROJECT_NAME} diff --git a/templates/template.cpp b/templates/template.cpp index 1d75668..bcc46f7 100644 --- a/templates/template.cpp +++ b/templates/template.cpp @@ -9,7 +9,7 @@ Author: likepeng #include #include -#include "myframe/export.h" +#include "export.h" #include "myframe/msg.h" #include "myframe/actor.h" #include "myframe/worker.h" @@ -54,7 +54,7 @@ class @template_name@Worker : public myframe::Worker { }; /* create actor instance */ -extern "C" MYFRAME_EXPORT std::shared_ptr actor_create( +extern "C" MYFRAME_SUBMODULE_EXPORT std::shared_ptr actor_create( const std::string& actor_name) { if (actor_name == "@template_name@") { return std::make_shared<@template_name@Actor>(); @@ -63,7 +63,7 @@ extern "C" MYFRAME_EXPORT std::shared_ptr actor_create( } /* create worker instance */ -extern "C" MYFRAME_EXPORT std::shared_ptr worker_create( +extern "C" MYFRAME_SUBMODULE_EXPORT std::shared_ptr worker_create( const std::string& worker_name) { if (worker_name == "@template_name@") { return std::make_shared<@template_name@Worker>();