From 073c7af868ddb423795284f0e32073222f486a1f Mon Sep 17 00:00:00 2001 From: david parsons Date: Sun, 7 Oct 2018 10:07:41 -0700 Subject: [PATCH] patch the cmakefile so that has an option to only generate a library --- cmake/CMakeLists.txt | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 2c39f4c..3895fdb 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -17,6 +17,9 @@ set(${PROJECT_NAME}_MAKE_INSTALL ON CACHE BOOL set(${PROJECT_NAME}_INSTALL_SAMPLES OFF CACHE BOOL "Set to ON to install sample programs (default is OFF)") +set(${PROJECT_NAME}_ONLY_LIBRARY OFF CACHE BOOL + "Set to ON to only build markdown library (default is OFF)") + # Check headers include(CheckIncludeFile) check_include_file(libgen.h HAVE_LIBGEN_H) @@ -141,28 +144,30 @@ add_library(libmarkdown set_target_properties(libmarkdown PROPERTIES OUTPUT_NAME markdown) -add_library(common OBJECT - "${_ROOT}/pgm_options.c" - "${_ROOT}/gethopt.c") +if(NOT ${PROJECT_NAME}_ONLY_LIBRARY) + add_library(common OBJECT + "${_ROOT}/pgm_options.c" + "${_ROOT}/gethopt.c") -add_executable(markdown - "${_ROOT}/main.c" - $) + add_executable(markdown + "${_ROOT}/main.c" + $) -target_link_libraries(markdown PRIVATE libmarkdown) + target_link_libraries(markdown PRIVATE libmarkdown) -add_executable(mkd2html - "${_ROOT}/mkd2html.c" - $ - "${_ROOT}/notspecial.c") + add_executable(mkd2html + "${_ROOT}/mkd2html.c" + $ + "${_ROOT}/notspecial.c") -target_link_libraries(mkd2html PRIVATE libmarkdown) + target_link_libraries(mkd2html PRIVATE libmarkdown) -add_executable(makepage - "${_ROOT}/makepage.c" - $) + add_executable(makepage + "${_ROOT}/makepage.c" + $) -target_link_libraries(makepage PRIVATE libmarkdown) + target_link_libraries(makepage PRIVATE libmarkdown) +endif() if(${PROJECT_NAME}_MAKE_INSTALL) string(TOLOWER ${PROJECT_NAME} _PACKAGE_NAME)