From f222b8e2ef1ffcd18c6093cd1272fd9e8b757291 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 24 Nov 2014 21:09:09 +0100 Subject: Cast void* for MSVC compatibility --- src/blocks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/blocks.c b/src/blocks.c index 5328638..6f995b3 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -439,7 +439,8 @@ extern cmark_node *cmark_parse_document(const char *buffer, size_t len) cmark_node *document; while (buffer < end) { - const char *eol = memchr(buffer, '\n', end - buffer); + const char *eol + = (const char *)memchr(buffer, '\n', end - buffer); offset = eol ? (eol - buffer) + 1 : end - buffer; cmark_process_line(parser, buffer, offset); buffer += offset; -- cgit v1.2.3 From 79ea99b9eb6c3ae8f40cf52da0c0dd2b998d6bf4 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 24 Nov 2014 21:09:53 +0100 Subject: Set test environment on Windows Add directory containing cmark.dll to PATH on Windows. --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb1944b..e554266 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,12 @@ add_test(spectest_library "${CMAKE_SOURCE_DIR}/spec.txt" "--library-dir" "${CMAKE_BINARY_DIR}/src" ) add_test(NAME api_test COMMAND api_test) +if (WIN32) + file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR}/src WIN_DLL_DIR) + set_tests_properties(api_test PROPERTIES + ENVIRONMENT "PATH=${WIN_DLL_DIR};$ENV{PATH}" + ) +endif(WIN32) add_test(spectest_executable python "${CMAKE_SOURCE_DIR}/runtests.py" "--no-normalize" "--spec" "${CMAKE_SOURCE_DIR}/spec.txt" "--program" "${CMAKE_BINARY_DIR}/src/cmark" ) -- cgit v1.2.3 From 7a4cd7ed0f07d8c41408da02b2367c979d4ff86e Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 24 Nov 2014 21:35:53 +0100 Subject: Run nmake test with /nologo --- Makefile.nmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.nmake b/Makefile.nmake index 0352b6d..54034c4 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -33,7 +33,7 @@ man\man1\cmark.1: man\cmark.1.md pandoc $? -o $@ -s -t man test: $(SPEC) all - @pushd $(BUILDDIR) && $(MAKE) test ARGS="-V" && popd + @pushd $(BUILDDIR) && $(MAKE) /nologo test ARGS="-V" && popd distclean: clean del /q src\scanners.c 2> nul -- cgit v1.2.3 From 7e1d399584fd2eb0c8e6f49c473ff6b1a2a7ecf6 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 24 Nov 2014 21:59:30 +0100 Subject: Fix MSVC options Also disable some warnings. --- api_test/CMakeLists.txt | 17 +++++++++++------ src/CMakeLists.txt | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/api_test/CMakeLists.txt b/api_test/CMakeLists.txt index b2ab2c8..c25b6c1 100644 --- a/api_test/CMakeLists.txt +++ b/api_test/CMakeLists.txt @@ -10,10 +10,15 @@ include_directories( target_link_libraries(api_test libcmark) # Compiler flags -if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") - set_target_properties(api_test PROPERTIES COMPILE_FLAGS - "-std=c99 -Wall -Wextra" - ) -elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") - set_target_properties(api_test PROPERTIES COMPILE_FLAGS "/TP /W4") +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} /wd4127 /wd4244 /wd4267 /wd4706 /wd4800 /D_CRT_SECURE_NO_WARNINGS") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP") +elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c99 -pedantic") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 71f45a7..f71f09c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -121,13 +121,14 @@ if(MSVC) else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") endif() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127 /wd4244 /wd4267 /wd4706 /wd4800 /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 -std=c99 -pedantic") endif() # Compile as C++ under MSVC if(MSVC) - set(CMAKE_C_FLAGS "/TP") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP") endif() if($ENV{TIMER}) -- cgit v1.2.3 From 3248516179ea8618333f8db31500d8a53e3184f0 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 24 Nov 2014 22:01:45 +0100 Subject: Build instructions for MSVC/NMAKE --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index b795b40..43b1769 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,10 @@ To test the archives: Compiling for Windows --------------------- +To compile with MSVC and NMAKE: + + nmake + You can cross-compile a Windows binary and dll on linux if you have the `mingw32` compiler: -- cgit v1.2.3 From 9de6890f11cf6d1947132bbf90e3735aabb0a683 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 16 Nov 2014 16:30:42 +0100 Subject: Add option to select cmake generator This allows to build under MSYS. The MSYS generator can be selected with make GENERATOR="MSYS Makefiles" But the default "UNIX Makefiles" generator also seems to work. --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4f8b15b..7d7e78c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ SRCDIR?=src DATADIR?=data BUILDDIR?=build +GENERATOR?=Unix Makefiles MINGW_BUILDDIR?=build-mingw MINGW_INSTALLDIR?=windows SPEC=spec.txt @@ -28,7 +29,7 @@ check: $(BUILDDIR): check mkdir -p $(BUILDDIR); \ cd $(BUILDDIR); \ - cmake .. -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) + cmake .. -G "$(GENERATOR)" -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) install: $(BUILDDIR) man/man1/cmark.1 make -C $(BUILDDIR) install -- cgit v1.2.3