chore: support windows static lib build
Cherry-picked from: marcoesposito1988/kdl_parser@472f8bf
This commit is contained in:
parent
f49e4991db
commit
d99508b29e
|
@ -99,6 +99,7 @@ else()
|
|||
find_package(tinyxml REQUIRED CONFIG)
|
||||
find_package(tinyxml2 REQUIRED CONFIG)
|
||||
add_library(${PROJECT_NAME} src/kdl_parser.cpp)
|
||||
|
||||
if(WIN32)
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "KDL_PARSER_BUILDING_DLL")
|
||||
|
|
|
@ -45,10 +45,6 @@ class kdl_parserRecipe(ConanFile):
|
|||
self.options.rm_safe("fPIC")
|
||||
|
||||
def configure(self):
|
||||
if self.settings.os == "Windows" and not self.options.shared:
|
||||
raise ConanInvalidConfiguration(
|
||||
"Static libraries are not supported on Windows. Please set option 'shared=True'."
|
||||
)
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
|
||||
|
@ -59,6 +55,8 @@ class kdl_parserRecipe(ConanFile):
|
|||
deps = CMakeDeps(self)
|
||||
deps.generate()
|
||||
tc = CMakeToolchain(self)
|
||||
if(not self.options.shared):
|
||||
tc.preprocessor_definitions["KDL_PARSER_STATIC"] = ""
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
|
@ -75,3 +73,5 @@ class kdl_parserRecipe(ConanFile):
|
|||
|
||||
def package_info(self):
|
||||
self.cpp_info.libs = ["kdl_parser"]
|
||||
if not self.options.shared:
|
||||
self.cpp_info.defines = ["KDL_PARSER_STATIC"]
|
|
@ -46,6 +46,13 @@
|
|||
// https://gcc.gnu.org/wiki/Visibility
|
||||
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
#ifdef KDL_PARSER_STATIC
|
||||
#define KDL_PARSER_EXPORT
|
||||
#define KDL_PARSER_IMPORT
|
||||
#define KDL_PARSER_PUBLIC
|
||||
#define KDL_PARSER_LOCAL
|
||||
#define KDL_PARSER_DEPRECATED(msg) __declspec(deprecated(msg))
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#define KDL_PARSER_EXPORT __attribute__ ((dllexport))
|
||||
#define KDL_PARSER_IMPORT __attribute__ ((dllimport))
|
||||
|
@ -62,6 +69,7 @@
|
|||
#endif
|
||||
#define KDL_PARSER_PUBLIC_TYPE KDL_PARSER_PUBLIC
|
||||
#define KDL_PARSER_LOCAL
|
||||
#endif
|
||||
#else
|
||||
#define KDL_PARSER_EXPORT __attribute__ ((visibility("default")))
|
||||
#define KDL_PARSER_IMPORT
|
||||
|
|
Loading…
Reference in New Issue