@@ -34,33 +34,15 @@ set(docopt_HEADERS
34
34
#============================================================================
35
35
# Compile targets
36
36
#============================================================================
37
- if (MSVC OR XCODE )
38
- # MSVC requires __declspec() attributes, which are achieved via the
39
- # DOCOPT_DLL and DOCOPT_EXPORTS macros below. Since those macros are only
40
- # defined when building a shared library, we must build the shared and
41
- # static libraries completely separately.
42
- # Xcode does not support libraries with only object files as sources.
43
- # See https://cmake.org/cmake/help/v3.0/command/add_library.html?highlight=add_library
44
- add_library (docopt SHARED ${docopt_SOURCES} ${docopt_HEADERS} )
45
- add_library (docopt_s STATIC ${docopt_SOURCES} ${docopt_HEADERS} )
46
- else ()
47
- # If not using MSVC or Xcode, we will create an intermediate object target
48
- # to avoid compiling the source code twice.
49
- add_library (docopt_o OBJECT ${docopt_SOURCES} ${docopt_HEADERS} )
50
- set_target_properties (docopt_o PROPERTIES POSITION_INDEPENDENT_CODE TRUE )
51
-
52
- add_library (docopt SHARED $< TARGET_OBJECTS:docopt_o> )
53
- set_target_properties (docopt PROPERTIES
54
- VERSION ${PROJECT_VERSION}
55
- SOVERSION ${PROJECT_VERSION_MAJOR}
56
- )
57
- add_library (docopt_s STATIC $< TARGET_OBJECTS:docopt_o> )
58
- endif ()
37
+ add_library (docopt ${docopt_SOURCES} ${docopt_HEADERS} )
38
+ set_target_properties (docopt PROPERTIES
39
+ VERSION ${PROJECT_VERSION}
40
+ SOVERSION ${PROJECT_VERSION_MAJOR}
41
+ )
59
42
60
43
target_include_directories (docopt PUBLIC $< BUILD_INTERFACE:${PROJECT_SOURCE_DIR} > $< INSTALL_INTERFACE:include/docopt> )
61
- target_include_directories (docopt_s PUBLIC $< BUILD_INTERFACE:${PROJECT_SOURCE_DIR} > $< INSTALL_INTERFACE:include/docopt> )
62
44
63
- if (MSVC )
45
+ if (MSVC AND BUILD_SHARED_LIBS )
64
46
# DOCOPT_DLL: Must be specified when building *and* when using the DLL.
65
47
# That's what the "PUBLIC" means.
66
48
# DOCOPT_EXPORTS: Must use __declspec(dllexport) when building the DLL.
@@ -69,11 +51,6 @@ if(MSVC)
69
51
PRIVATE DOCOPT_EXPORTS )
70
52
endif ()
71
53
72
- if (NOT MSVC )
73
- set_target_properties (docopt PROPERTIES OUTPUT_NAME docopt )
74
- set_target_properties (docopt_s PROPERTIES OUTPUT_NAME docopt )
75
- endif ()
76
-
77
54
if (USE_BOOST_REGEX )
78
55
add_definitions ("-DDOCTOPT_USE_BOOST_REGEX" )
79
56
# This is needed on Linux, where linking a static library into docopt.so
@@ -82,9 +59,6 @@ if(USE_BOOST_REGEX)
82
59
find_package (Boost 1.53 REQUIRED COMPONENTS regex )
83
60
include_directories (${Boost_INCLUDE_DIRS} )
84
61
target_link_libraries (docopt ${Boost_LIBRARIES} )
85
- if (WITH_STATIC )
86
- target_link_libraries (docopt_s ${Boost_LIBRARIES} )
87
- endif ()
88
62
endif ()
89
63
90
64
#============================================================================
@@ -120,7 +94,6 @@ set(export_name "docopt-targets")
120
94
install (TARGETS docopt EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR} )
121
95
122
96
# Development package
123
- install (TARGETS docopt_s EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR} )
124
97
install (FILES ${docopt_HEADERS} DESTINATION include /docopt )
125
98
126
99
# CMake Package
0 commit comments