Commit bfca107d3485b44466839096903c75e151c3da95

Martin Mitas 2019-02-08T09:23:20

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

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}