Build: Allow again building MD4C as static lib. * On Windows, we build static lib by default, as there is no /usr/lib counterpart. * On other systems the shared lib is the default. * Use option BUILD_SHARED_LIBS to override it: $ cmake -DBUILD_SHARED_LIBS=ON path_to_root # to build shared lib $ cmake -DBUILD_SHARED_LIBS=OFF path_to_root # to build static lib
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5239802..a34fca4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,16 @@ set(MD_VERSION_MINOR 2)
set(MD_VERSION_RELEASE 7)
set(MD_VERSION "${MD_VERSION_MAJOR}.${MD_VERSION_MINOR}.${MD_VERSION_RELEASE}")
+if(WIN32)
+ # On Windows, given there is no standard lib install dir etc., we rather
+ # by default build static lib.
+ option(BUILD_SHARED_LIBS "help string describing option" OFF)
+else()
+ # On Linux, MD4C is slowly being adding into some distros which prefer
+ # shared lib.
+ option(BUILD_SHARED_LIBS "help string describing option" ON)
+endif()
+
add_definitions(
-DMD_VERSION_MAJOR=${MD_VERSION_MAJOR}
-DMD_VERSION_MINOR=${MD_VERSION_MINOR}
diff --git a/md4c/CMakeLists.txt b/md4c/CMakeLists.txt
index 8fc846f..4e3e42d 100644
--- a/md4c/CMakeLists.txt
+++ b/md4c/CMakeLists.txt
@@ -9,7 +9,7 @@ set(md4c_src
md4c.c
)
-add_library(md4c SHARED ${md4c_src})
+add_library(md4c ${md4c_src})
set_target_properties(md4c PROPERTIES
VERSION ${MD_VERSION}
@@ -20,6 +20,7 @@ set_target_properties(md4c PROPERTIES
install(
TARGETS md4c
EXPORT md4cConfig
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}