Browse Source

Travis CI: Add test case for pkg-config

Ahmad Fatoum 7 years ago
parent
commit
c3aeaf4a49
4 changed files with 30 additions and 0 deletions
  1. 1 0
      .travis.yml
  2. 2 0
      CMakeLists.txt
  3. 21 0
      cmake/test-pkgconfig.sh
  4. 6 0
      src/CMakeLists.txt

+ 1 - 0
.travis.yml

@@ -96,6 +96,7 @@ script:
   - if [[ "$ARCH" != *-android && "$ARCH" != html5 ]]; then
   - if [[ "$ARCH" != *-android && "$ARCH" != html5 ]]; then
       pkg-config --static --libs raylib;
       pkg-config --static --libs raylib;
       nm -g release/libraylib.a | grep glfwGetProcAddress || (echo "libraylib.a doesn't contain GLFW symbols! Aborting..." && false);
       nm -g release/libraylib.a | grep glfwGetProcAddress || (echo "libraylib.a doesn't contain GLFW symbols! Aborting..." && false);
+      ctest --output-on-failure;
     fi
     fi
 
 
 deploy:
 deploy:

+ 2 - 0
CMakeLists.txt

@@ -50,3 +50,5 @@ endif()
 if (${BUILD_GAMES})
 if (${BUILD_GAMES})
   add_subdirectory(games)
   add_subdirectory(games)
 endif()
 endif()
+
+enable_testing()

+ 21 - 0
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

+ 6 - 0
src/CMakeLists.txt

@@ -144,6 +144,8 @@ if(${SHARED})
       PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
       PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
     )
     )
   endif()
   endif()
+
+  add_test("pkg-config" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh)
 endif(${SHARED})
 endif(${SHARED})
 
 
 if(${STATIC})
 if(${STATIC})
@@ -167,6 +169,8 @@ if(${STATIC})
     ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
     ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
     PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
     PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
   )
   )
+
+  add_test("pkg-config--static" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh --static)
 endif(${STATIC})
 endif(${STATIC})
 
 
 configure_file(../raylib.pc.in raylib.pc @ONLY)
 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_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
 SET(CPACK_GENERATOR "ZIP;TGZ") # Remove this, if you want the NSIS installer on Windows
 include(CPack)
 include(CPack)
+
+enable_testing()