Skip to content

Commit

Permalink
submodule use self export file
Browse files Browse the repository at this point in the history
  • Loading branch information
lkpworkspace committed Feb 17, 2024
1 parent 565577f commit fa5b04e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 8 additions & 2 deletions templates/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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("$<$<CXX_COMPILER_ID:MSVC>:/source-charset:utf-8>")

#### deps lib
Expand All @@ -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}
Expand Down
6 changes: 3 additions & 3 deletions templates/template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Author: likepeng <[email protected]>
#include <thread>
#include <iostream>

#include "myframe/export.h"
#include "export.h"
#include "myframe/msg.h"
#include "myframe/actor.h"
#include "myframe/worker.h"
Expand Down Expand Up @@ -54,7 +54,7 @@ class @template_name@Worker : public myframe::Worker {
};

/* create actor instance */
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
extern "C" MYFRAME_SUBMODULE_EXPORT std::shared_ptr<myframe::Actor> actor_create(
const std::string& actor_name) {
if (actor_name == "@template_name@") {
return std::make_shared<@template_name@Actor>();
Expand All @@ -63,7 +63,7 @@ extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
}

/* create worker instance */
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Worker> worker_create(
extern "C" MYFRAME_SUBMODULE_EXPORT std::shared_ptr<myframe::Worker> worker_create(
const std::string& worker_name) {
if (worker_name == "@template_name@") {
return std::make_shared<@template_name@Worker>();
Expand Down

0 comments on commit fa5b04e

Please sign in to comment.