Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: run CMakelint #463

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
# which is incompatible with static linking under certain configurations.
# Unsetting CMAKE_SHARED_LIBRARY_LINK_C_FLAGS ensures this does not happen.
if(CMARK_STATIC AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
endif()

# Check integrity of node structure when compiled as debug
Expand Down Expand Up @@ -76,4 +76,4 @@ endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Profile Release Asan Ubsan." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
endif()
24 changes: 12 additions & 12 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,27 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark_version.h.in
${CMAKE_CURRENT_BINARY_DIR}/cmark_version.h)

include(GNUInstallDirs)
include (GenerateExportHeader)
include(GenerateExportHeader)

add_executable(${PROGRAM} ${PROGRAM_SOURCES})
cmark_add_compile_options(${PROGRAM})
set_target_properties(${PROGRAM} PROPERTIES
OUTPUT_NAME "cmark")

if (CMARK_STATIC)
if(CMARK_STATIC)
target_link_libraries(${PROGRAM} ${STATICLIBRARY})
# Disable the PUBLIC declarations when compiling the executable:
set_target_properties(${PROGRAM} PROPERTIES
COMPILE_FLAGS -DCMARK_STATIC_DEFINE)
elseif (CMARK_SHARED)
elseif(CMARK_SHARED)
target_link_libraries(${PROGRAM} ${LIBRARY})
endif()

# -fvisibility=hidden
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)

if (CMARK_SHARED)
if(CMARK_SHARED)
add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})
cmark_add_compile_options(${LIBRARY})
set_target_properties(${LIBRARY} PROPERTIES
Expand All @@ -93,7 +93,7 @@ if (CMARK_SHARED)
list(APPEND CMARK_INSTALL ${LIBRARY})
endif()

if (CMARK_STATIC)
if(CMARK_STATIC)
add_library(${STATICLIBRARY} STATIC ${LIBRARY_SOURCES})
cmark_add_compile_options(${STATICLIBRARY})
set_target_properties(${STATICLIBRARY} PROPERTIES
Expand All @@ -113,18 +113,18 @@ if (CMARK_STATIC)
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
add_library(cmark::cmark_static ALIAS ${STATICLIBRARY})

if (NOT CMARK_SHARED)
if(NOT CMARK_SHARED)
generate_export_header(${STATICLIBRARY}
BASE_NAME ${PROJECT_NAME})
endif()

list(APPEND CMARK_INSTALL ${STATICLIBRARY})
endif()

if (MSVC)
if(MSVC)
set_property(TARGET ${PROGRAM}
APPEND PROPERTY LINK_FLAGS /INCREMENTAL:NO)
endif(MSVC)
endif()

if(NOT MSVC OR CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
Expand Down Expand Up @@ -182,16 +182,16 @@ endif()
# Feature tests
include(CheckIncludeFile)
include(CheckCSourceCompiles)
CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
CHECK_C_SOURCE_COMPILES(
check_include_file(stdbool.h HAVE_STDBOOL_H)
check_c_source_compiles(
"int main() { __builtin_expect(0,0); return 0; }"
HAVE___BUILTIN_EXPECT)
CHECK_C_SOURCE_COMPILES("
check_c_source_compiles("
int f(void) __attribute__ (());
int main() { return 0; }
" HAVE___ATTRIBUTE__)

CONFIGURE_FILE(
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)

Expand Down
22 changes: 11 additions & 11 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@
# By default, we run the spec tests only if python3 is available.
# To require the spec tests, compile with -DSPEC_TESTS=1

if (SPEC_TESTS)
if(SPEC_TESTS)
find_package(PythonInterp 3 REQUIRED)
else(SPEC_TESTS)
else()
find_package(PythonInterp 3)
endif(SPEC_TESTS)
endif()

if (CMARK_SHARED OR CMARK_STATIC)
if(CMARK_SHARED OR CMARK_STATIC)
add_test(NAME api_test COMMAND api_test)
endif()

if (WIN32)
if(WIN32)
file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR}/src WIN_DLL_DIR)
set(NEWPATH "${WIN_DLL_DIR};$ENV{PATH}")
string(REPLACE ";" "\\;" NEWPATH "${NEWPATH}")
set_tests_properties(api_test PROPERTIES ENVIRONMENT "PATH=${NEWPATH}")
set(ROUNDTRIP "${CMAKE_CURRENT_SOURCE_DIR}/roundtrip.bat")
else(WIN32)
else()
set(ROUNDTRIP "${CMAKE_CURRENT_SOURCE_DIR}/roundtrip.sh")
endif(WIN32)
endif()

IF (PYTHONINTERP_FOUND)
if(PYTHONINTERP_FOUND)

add_test(html_normalization
${PYTHON_EXECUTABLE} "-m" "doctest"
"${CMAKE_CURRENT_SOURCE_DIR}/normalize.py"
)

if (CMARK_SHARED)
if(CMARK_SHARED)
add_test(spectest_library
${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py" "--no-normalize" "--spec"
"${CMAKE_CURRENT_SOURCE_DIR}/spec.txt" "--library-dir" "${CMAKE_CURRENT_BINARY_DIR}/../src"
Expand Down Expand Up @@ -70,11 +70,11 @@ IF (PYTHONINTERP_FOUND)
"${CMAKE_CURRENT_BINARY_DIR}/../src/cmark"
)

ELSE(PYTHONINTERP_FOUND)
else()

message("\n*** A python 3 interpreter is required to run the spec tests.\n")
add_test(skipping_spectests
echo "Skipping spec tests, because no python 3 interpreter is available.")

ENDIF(PYTHONINTERP_FOUND)
endif()