Skip to content

Building with CMARK_SHARED=OFF fails #247

@ericpruitt

Description

@ericpruitt

I'm attempting to build a static cmark binary by setting the cmake option "CMARK_SHARED" to "OFF", but the cmark binary fails to build. This is the script I'm using:

rm -rf CMakeFiles/ CMakeCache.txt build/ && ( mkdir -p build && cd build/ && cmake -G "Unix Makefiles" \ -DCMAKE_BUILD_TYPE= \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ -DCMARK_TESTS=OFF -DCMARK_SHARED=OFF .. && make )

The build fails because the compiler is unable to locate some source files. All failed builds show the exact same error:

In file included from /home/ericpruitt/projects/mdlint/cmark/src/node.h:11:0, from /home/ericpruitt/projects/mdlint/cmark/src/node.c:5: /home/ericpruitt/projects/mdlint/cmark/src/cmark.h:5:26: fatal error: cmark_export.h: No such file or directory #include <cmark_export.h> ^ compilation terminated.

Here's the diff of the generated Makefiles with CMAKE_SHARED=ON/OFF:

--- CMAKE_SHARED=ON 2017-11-11 19:01:31.807657734 -0800 +++ CMAKE_SHARED=OFF 2017-11-11 19:08:02.069241357 -0800 @@ -168,19 +168,6 @@ .PHONY : cmark/fast #============================================================================= -# Target rules for targets named libcmark - -# Build rule for target. -libcmark: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 libcmark -.PHONY : libcmark - -# fast build rule for target. -libcmark/fast: - $(MAKE) -f src/CMakeFiles/libcmark.dir/build.make src/CMakeFiles/libcmark.dir/build -.PHONY : libcmark/fast - -#============================================================================= # Target rules for targets named libcmark_static # Build rule for target. @@ -206,7 +193,6 @@ @echo "... list_install_components" @echo "... install" @echo "... cmark" - @echo "... libcmark" @echo "... libcmark_static" .PHONY : help

A year and a half ago, I opened #129 , and I was able to build just a static cmark binary by modifying CMakeFiles.txt at your recommendation, but that no longer works either:

cmark [1]$ git diff src/CMakeLists.txt | cat diff --git src/CMakeLists.txt src/CMakeLists.txt index d5a1936..7014bd5 100644 --- src/CMakeLists.txt +++ src/CMakeLists.txt @@ -80,7 +80,7 @@ elseif(CMAKE_COMPILER_IS_GNUCC OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") endif () if (CMARK_SHARED) - add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES}) + #add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES}) # Include minor version and patch level in soname for now. set_target_properties(${LIBRARY} PROPERTIES OUTPUT_NAME "cmark" cmark$ make clean rm -rf build build-mingw windows cmark$ make mkdir -p build; \ cd build; \ cmake .. \ -G "Unix Makefiles" \ -DCMAKE_BUILD_TYPE= \ -DCMAKE_INSTALL_PREFIX=/usr/local \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -- The C compiler identification is GNU 6.3.0 -- The CXX compiler identification is GNU 6.3.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test HAVE_FLAG_ADDRESS_SANITIZER -- Performing Test HAVE_FLAG_ADDRESS_SANITIZER - Failed -- Performing Test HAVE_FLAG_SANITIZE_ADDRESS -- Performing Test HAVE_FLAG_SANITIZE_ADDRESS - Success -- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY -- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success -- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY -- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success -- Performing Test COMPILER_HAS_DEPRECATED_ATTR -- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success CMake Error at src/CMakeLists.txt:85 (set_target_properties): set_target_properties Can not find target to add properties to: libcmark CMake Error at src/CMakeLists.txt:90 (set_property): set_property could not find TARGET libcmark. Perhaps it has not yet been created. CMake Error at src/CMakeLists.txt:94 (set_target_properties): set_target_properties Can not find target to add properties to: libcmark CMake Error at /usr/share/cmake-3.7/Modules/GenerateExportHeader.cmake:370 (get_property): get_property could not find TARGET libcmark. Perhaps it has not yet been created. Call Stack (most recent call first): src/CMakeLists.txt:96 (generate_export_header) CMake Error at src/CMakeLists.txt:131 (install): install TARGETS given target "libcmark" which does not exist in this directory. -- Looking for stdbool.h -- Looking for stdbool.h - found -- Performing Test HAVE___BUILTIN_EXPECT -- Performing Test HAVE___BUILTIN_EXPECT - Success -- Performing Test HAVE___ATTRIBUTE__ -- Performing Test HAVE___ATTRIBUTE__ - Success -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.5.3", minimum required is "3") -- Configuring incomplete, errors occurred! See also "/home/ericpruitt/projects/mdlint/cmark/build/CMakeFiles/CMakeOutput.log". See also "/home/ericpruitt/projects/mdlint/cmark/build/CMakeFiles/CMakeError.log". Makefile:37: recipe for target 'build' failed make: *** [build] Error 1 (2)

How should I go about build a static cmark binary now?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions