summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAhmad Fatoum <[email protected]>2018-07-03 20:34:31 +0200
committerAhmad Fatoum <[email protected]>2018-07-03 21:35:28 +0200
commitc3aeaf4a4941514653b9e3f3b7e1ea0965ef925f (patch)
tree90dcf9d458c6c4ea9bea727b2e802a94930fb991
parent61747508b0b0ee77b1de40a1c7f0a483c1a07e05 (diff)
downloadraylib-c3aeaf4a4941514653b9e3f3b7e1ea0965ef925f.tar.gz
raylib-c3aeaf4a4941514653b9e3f3b7e1ea0965ef925f.zip
Travis CI: Add test case for pkg-config
-rw-r--r--.travis.yml1
-rw-r--r--CMakeLists.txt2
-rwxr-xr-xcmake/test-pkgconfig.sh21
-rw-r--r--src/CMakeLists.txt6
4 files changed, 30 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml
index 2fd73c18..f3c017ff 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -96,6 +96,7 @@ script:
- if [[ "$ARCH" != *-android && "$ARCH" != html5 ]]; then
pkg-config --static --libs raylib;
nm -g release/libraylib.a | grep glfwGetProcAddress || (echo "libraylib.a doesn't contain GLFW symbols! Aborting..." && false);
+ ctest --output-on-failure;
fi
deploy:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 34411b46..a61229ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,3 +50,5 @@ endif()
if (${BUILD_GAMES})
add_subdirectory(games)
endif()
+
+enable_testing()
diff --git a/cmake/test-pkgconfig.sh b/cmake/test-pkgconfig.sh
new file mode 100755
index 00000000..ccbdfb65
--- /dev/null
+++ b/cmake/test-pkgconfig.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Test if including/linking/running an installed raylib works
+
+set -x
+export LD_RUN_PATH=/usr/local/lib
+
+CFLAGS="-Wall -Wextra -Werror $CFLAGS"
+if [ "$ARCH" = "i386" ]; then
+CFLAGS="-m32 $CLFAGS"
+fi
+
+cat << EOF | ${CC:-cc} -otest -xc - $(pkg-config --libs --cflags $@ raylib.pc) $CFLAGS && exec ./test
+#include <stdlib.h>
+#include <raylib.h>
+
+int main(void)
+{
+ int num = GetRandomValue(42, 1337);
+ return 42 <= num && num <= 1337 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+EOF
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c2999c41..333bcf1d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -144,6 +144,8 @@ if(${SHARED})
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()
+
+ add_test("pkg-config" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh)
endif(${SHARED})
if(${STATIC})
@@ -167,6 +169,8 @@ if(${STATIC})
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
+
+ add_test("pkg-config--static" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh --static)
endif(${STATIC})
configure_file(../raylib.pc.in raylib.pc @ONLY)
@@ -203,3 +207,5 @@ SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../LICENSE.md")
SET(CPACK_PACKAGE_FILE_NAME "raylib-${PROJECT_VERSION}$ENV{RAYLIB_PACKAGE_SUFFIX}")
SET(CPACK_GENERATOR "ZIP;TGZ") # Remove this, if you want the NSIS installer on Windows
include(CPack)
+
+enable_testing()