Fix build!

master
Melroy van den Berg 2020-11-20 23:41:12 +01:00
parent 0c7a290075
commit 609871ee44
4 changed files with 39 additions and 46 deletions

View File

@ -16,8 +16,6 @@ message("PROJECT_VERSION = ${PROJECT_VERSION}")
# Production build
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
add_definitions(-DPRODUCTION=1)
# Include CPack packaging settings
include(packaging)
endif()

View File

@ -1,14 +1,18 @@
set(LIBRARY "LibCommonMarkerExtensions")
set (LIBRARY_SOURCES
core-extensions.c
table.c
strikethrough.c
autolink.c
tagfilter.c
ext_scanners.c
ext_scanners.re
ext_scanners.h
tasklist.c
)
core-extensions.c
table.c
strikethrough.c
autolink.c
tagfilter.c
ext_scanners.c
ext_scanners.re
ext_scanners.h
tasklist.c
)
set_property(GLOBAL PROPERTY COMMONMARKER_EXTENSIONS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
include_directories (
${PROJECT_SOURCE_DIR}/lib/commonmarker/src
@ -18,5 +22,14 @@ include_directories (
include (GenerateExportHeader)
include_directories (. ${CMAKE_CURRENT_BINARY_DIR})
add_library (LibCommonMarkerExtensions ${LIBRARY_SOURCES})
target_link_libraries(LibCommonMarkerExtensions LibCommonMarker)
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
set(CMAKE_LINKER_PROFILE "${CMAKE_LINKER_FLAGS_RELEASE} -pg")
add_library(${LIBRARY} ${LIBRARY_SOURCES})
target_include_directories(${LIBRARY} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
# Generate export.h
generate_export_header(${LIBRARY}
BASE_NAME cmark-gfm-extensions)
target_link_libraries(${LIBRARY} LibCommonMarker)

View File

@ -3,7 +3,7 @@ set(PROJECT_VERSION_MINOR 29)
set(PROJECT_VERSION_PATCH 0)
set(PROJECT_VERSION_GFM 0)
set (CMAKE_INCLUDE_CURRENT_DIR ON)
set(LIBRARY "LibCommonMarker")
set(HEADERS
cmark-gfm.h
@ -25,7 +25,7 @@ set(HEADERS
registry.h
syntax_extension.h
plugin.h
)
)
set(LIBRARY_SOURCES
cmark.c
node.c
@ -56,7 +56,7 @@ set(LIBRARY_SOURCES
registry.c
plugin.c
${HEADERS}
)
)
set_property(GLOBAL PROPERTY COMMONMARKER_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
@ -74,10 +74,6 @@ include (GenerateExportHeader)
set_target_properties(${PROGRAM} PROPERTIES
COMPILE_FLAGS "-DCMARK_STATIC_DEFINE -DCMARKEXTENSIONS_STATIC_DEFINE")
# Check integrity of node structure when compiled as debug:
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DCMARK_DEBUG_NODES -DDEBUG")
set(CMAKE_LINKER_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
set(CMAKE_LINKER_PROFILE "${CMAKE_LINKER_FLAGS_RELEASE} -pg")
@ -99,27 +95,9 @@ configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)
# Always compile with warnings
if(MSVC)
# Force to always compile with W4
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX /wd4706 /wd4204 /wd4221 /wd4100 /D_CRT_SECURE_NO_WARNINGS")
elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -std=c99 -pedantic")
endif()
add_library(${LIBRARY} ${LIBRARY_SOURCES})
target_include_directories(${LIBRARY} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
# Compile as C++ under MSVC older than 12.0
if(MSVC AND MSVC_VERSION LESS 1800)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Ubsan")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
endif()
add_library (LibCommonMarker ${LIBRARY_SOURCES})
target_include_directories(LibCommonMarker PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
# Generate export.h
generate_export_header(${LIBRARY}
BASE_NAME cmark-gfm)

View File

@ -45,7 +45,7 @@ set(SOURCES
)
# TODO: Why is the executable 'browser' detetected as shared lib? I Just want to have an executable
# Maybe because I build shared libs in other CMakeLists, .. uhm
# Maybe because I build shared libs in other CMakeLists, strange..?
if(ANDROID)
add_library (${PROJECT_TARGET} SHARED
${SOURCES}
@ -57,10 +57,14 @@ else()
endif()
# Get the cmark binary dir for config.h
# Add to include list the cmark binary directory for config.h, .._version.h & .._export.h
get_property(cmark_binary_dir GLOBAL PROPERTY COMMONMARKER_BINARY_DIR)
include_directories(${cmark_binary_dir})
# Add to include list the cmark extensions binary directory for ..._export.h
get_property(cmark_extensions_binary_dir GLOBAL PROPERTY COMMONMARKER_EXTENSIONS_BINARY_DIR)
include_directories(${cmark_extensions_binary_dir})
include_directories(lib/commonmarker/src)
# TODO: 1x target_link_libraries?