Permalink
Browse files

Add CMake build support

  • Loading branch information...
mnunberg committed Feb 8, 2014
1 parent ee2f09b commit 50cbd77506e389ade8fb8813838f9a6806d39e25
Showing with 41 additions and 12 deletions.
  1. +17 −0 CMakeLists.txt
  2. +0 −12 Makefile.mingw
  3. +18 −0 tests/CMakeLists.txt
  4. +2 −0 tests/fail-tests.c
  5. +4 −0 tests/json_test.c
View
@@ -0,0 +1,17 @@
+# This is here mainly to support Win32
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+ADD_DEFINITIONS(-DJSONSL_STATE_GENERIC)
+IF(MSVC)
+ ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
+ENDIF()
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+ADD_LIBRARY(jsonsl jsonsl.c)
+EXECUTE_PROCESS(
+ COMMAND
+ ${CMAKE_COMMAND} -E tar xzf ${CMAKE_CURRENT_SOURCE_DIR}/json_samples.tgz
+ WORKING_DIRECTORY
+ ${CMAKE_CURRENT_BINARY_DIR})
+
+
+ENABLE_TESTING()
+ADD_SUBDIRECTORY(tests)
View
@@ -1,12 +0,0 @@
-# I don't claim for this Makefile to be 'correct'
-# but it let me test some basic win32 stuff on debian
-# using the mingw32 package
-
-LIB_PREFIX=
-LIB_SUFFIX=.o
-STATIC_LIB=1
-CC=i586-mingw32msvc-gcc
-export STATIC_LIB
-export CC
-
-include Makefile
View
@@ -0,0 +1,18 @@
+ADD_EXECUTABLE(json_test json_test.c)
+TARGET_LINK_LIBRARIES(json_test jsonsl)
+
+ADD_EXECUTABLE(failure_test fail-tests.c)
+TARGET_LINK_LIBRARIES(failure_test jsonsl)
+
+ADD_EXECUTABLE(jpr_test jpr_test.c)
+TARGET_LINK_LIBRARIES(jpr_test jsonsl)
+ADD_EXECUTABLE(unescape unescape.c)
+TARGET_LINK_LIBRARIES(unescape jsonsl)
+
+FILE(GLOB samples_ok ${CMAKE_BINARY_DIR}/share/*
+ ${CMAKE_BINARY_DIR}/jsc/pass*.json)
+FILE(GLOB samples_bad ${CMAKE_BINARY_DIR}/share/jsc/fail*.json)
+ADD_TEST(okparse json_test ${samples_ok})
+ADD_TEST(badparse failure_test ${samples_bad})
+ADD_TEST(jsonpointer jpr_test)
+ADD_TEST(unescape unescape)
View
@@ -0,0 +1,2 @@
+#define JSONSL_FAILURE_TESTS
+#include "json_test.c"
View
@@ -156,10 +156,14 @@ JSONSL_TEST_JSON_FUNC
if (getenv("JSONSL_QUIET_TESTS")) {
freopen(DEVNULL, "w", stdout);
}
+#ifdef JSONSL_FAILURE_TESTS
+ WantFail = 1;
+#else
if (getenv("JSONSL_FAIL_TESTS")) {
printf("Want Fail..\n");
WantFail = 1;
}
+#endif
if (argc < 2) {
fprintf(stderr, "Usage: %s FILES..\n", argv[0]);
exit(EXIT_FAILURE);

0 comments on commit 50cbd77

Please sign in to comment.