summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt84
1 files changed, 48 insertions, 36 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2a4dc9f..f52ded6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -54,11 +54,6 @@ include_directories(. ${CMAKE_CURRENT_BINARY_DIR})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark_version.h.in
${CMAKE_CURRENT_BINARY_DIR}/cmark_version.h)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libcmark.pc.in
- ${CMAKE_CURRENT_BINARY_DIR}/libcmark.pc @ONLY)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcmark.pc
- DESTINATION lib${LIB_SUFFIX}/pkgconfig)
-
include (GenerateExportHeader)
add_executable(${PROGRAM} ${PROGRAM_SOURCES})
@@ -82,58 +77,75 @@ elseif(CMAKE_COMPILER_IS_GNUCC OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
endif ()
-add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})
-add_library(${STATICLIBRARY} STATIC ${LIBRARY_SOURCES})
-# Include minor version and patch level in soname for now.
-set_target_properties(${LIBRARY} PROPERTIES
- OUTPUT_NAME "cmark"
- SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
- VERSION ${PROJECT_VERSION})
-set_target_properties(${STATICLIBRARY} PROPERTIES
- COMPILE_FLAGS -DCMARK_STATIC_DEFINE
- POSITION_INDEPENDENT_CODE ON)
-
-if (MSVC)
- set_target_properties(${STATICLIBRARY} PROPERTIES
- OUTPUT_NAME "cmark_static"
- VERSION ${PROJECT_VERSION})
-else()
- set_target_properties(${STATICLIBRARY} PROPERTIES
+if (CMARK_SHARED)
+ add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})
+ # Include minor version and patch level in soname for now.
+ set_target_properties(${LIBRARY} PROPERTIES
OUTPUT_NAME "cmark"
+ SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
VERSION ${PROJECT_VERSION})
-endif(MSVC)
-set_property(TARGET ${LIBRARY}
- APPEND PROPERTY MACOSX_RPATH true)
+ set_property(TARGET ${LIBRARY}
+ APPEND PROPERTY MACOSX_RPATH true)
-# Avoid name clash between PROGRAM and LIBRARY pdb files.
-set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmark_dll)
+ # Avoid name clash between PROGRAM and LIBRARY pdb files.
+ set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmark_dll)
-generate_export_header(${LIBRARY}
+ generate_export_header(${LIBRARY}
BASE_NAME ${PROJECT_NAME})
+ list(APPEND CMARK_INSTALL ${LIBRARY})
+endif()
+
+if (CMARK_STATIC)
+ add_library(${STATICLIBRARY} STATIC ${LIBRARY_SOURCES})
+ set_target_properties(${STATICLIBRARY} PROPERTIES
+ COMPILE_FLAGS -DCMARK_STATIC_DEFINE
+ POSITION_INDEPENDENT_CODE ON)
+
+ if (MSVC)
+ set_target_properties(${STATICLIBRARY} PROPERTIES
+ OUTPUT_NAME "cmark_static"
+ VERSION ${PROJECT_VERSION})
+ else()
+ set_target_properties(${STATICLIBRARY} PROPERTIES
+ OUTPUT_NAME "cmark"
+ VERSION ${PROJECT_VERSION})
+ endif(MSVC)
+
+ list(APPEND CMARK_INSTALL ${STATICLIBRARY})
+endif()
+
if (MSVC)
set_property(TARGET ${PROGRAM}
APPEND PROPERTY LINK_FLAGS /INCREMENTAL:NO)
endif(MSVC)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
+
include (InstallRequiredSystemLibraries)
-install(TARGETS ${PROGRAM} ${LIBRARY} ${STATICLIBRARY}
+install(TARGETS ${PROGRAM} ${CMARK_INSTALL}
EXPORT cmark
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
)
-install(FILES
- cmark.h
- ${CMAKE_CURRENT_BINARY_DIR}/cmark_export.h
- ${CMAKE_CURRENT_BINARY_DIR}/cmark_version.h
- DESTINATION include
- )
+if(CMARK_SHARED OR CMARK_STATIC)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libcmark.pc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/libcmark.pc @ONLY)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcmark.pc
+ DESTINATION lib${LIB_SUFFIX}/pkgconfig)
-install(EXPORT cmark DESTINATION lib${LIB_SUFFIX}/cmake)
+ install(FILES
+ cmark.h
+ ${CMAKE_CURRENT_BINARY_DIR}/cmark_export.h
+ ${CMAKE_CURRENT_BINARY_DIR}/cmark_version.h
+ DESTINATION include
+ )
+
+ install(EXPORT cmark DESTINATION lib${LIB_SUFFIX}/cmake)
+endif()
# Feature tests
include(CheckIncludeFile)