sdl12-compat: Add all the test programs into the build and compile by default.

From 40572e66e13b3be3affb5e4a64a20d9f6fa67c51 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 24 May 2021 10:50:37 -0400
Subject: [PATCH] Add all the test programs into the build and compile by
 default.

Now that we have 1.2 headers guaranteed to exist.  :)
---
 CMakeLists.txt | 45 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 42 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4adade0..9bdb259 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,9 @@
 cmake_minimum_required(VERSION 3.0.0)
 project(sdl12_compat)
 
-option(SDL12TESTS "Enable to build SDL-1.2 test programs" OFF)
+option(SDL12TESTS "Enable to build SDL-1.2 test programs" ON)
+
+set(CMAKE_SKIP_RPATH TRUE)
 
 if(APPLE)
   set(OSX_SRCS "src/SDL12_compat_objc.m")
@@ -80,21 +82,58 @@ endif()
 
 
 if(SDL12TESTS)
-    include(FindSDL)
     if(NOT (WIN32 OR APPLE OR CYGWIN OR HAIKU OR BEOS))
       find_library(MATH_LIBRARY m)
     endif()
 
     macro(test_program _NAME _SRCS)
         add_executable(${_NAME} ${_SRCS})
-        target_include_directories(${_NAME} PRIVATE ${SDL_INCLUDE_DIR})
+        target_include_directories(${_NAME} PRIVATE "include/SDL")
         target_link_libraries(${_NAME} SDL)
+        set_target_properties(${_NAME} PROPERTIES COMPILE_DEFINITIONS "HAVE_OPENGL")
         if(MATH_LIBRARY)
           target_link_libraries(${_NAME} ${MATH_LIBRARY})
         endif()
     endmacro()
 
+    test_program(checkkeys "test/checkkeys.c")
+    test_program(graywin "test/graywin.c")
+    test_program(loopwave "test/loopwave.c")
+    test_program(testalpha "test/testalpha.c")
+    test_program(testbitmap "test/testbitmap.c")
+    test_program(testblitspeed "test/testblitspeed.c")
+    test_program(testcdrom "test/testcdrom.c")
+    test_program(testcursor "test/testcursor.c")
+    test_program(testdyngl "test/testdyngl.c")
+    test_program(testerror "test/testerror.c")
+    test_program(testfile "test/testfile.c")
+    test_program(testgamma "test/testgamma.c")
+    test_program(testgl "test/testgl.c")
+    test_program(testthread "test/testhread.c")
+    test_program(testiconv "test/testiconv.c")
+    test_program(testjoystick "test/testjoystick.c")
+    test_program(testkeys "test/testkeys.c")
+    test_program(testloadso "test/testloadso.c")
+    test_program(testlock "test/testlock.c")
+    test_program(testoverlay "test/testoverlay.c")
+    test_program(testoverlay2 "test/testoverlay2.c")
+    test_program(testpalette "test/testpalette.c")
+    test_program(testplatform "test/testplatform.c")
+    test_program(testsem "test/testsem.c")
     test_program(testsprite "test/testsprite.c")
+    test_program(testtimer "test/testtimer.c")
+    test_program(testver "test/testver.c")
+    test_program(testvidinfo "test/testvidinfo.c")
+    test_program(testwin "test/testwin.c")
+    test_program(testwm "test/testwm.c")
+    test_program(threadwin "test/threadwin.c")
+    test_program(torturethread "test/torturethread.c")
+
+    if(APPLE)
+        target_link_libraries(testgl PRIVATE "-framework OpenGL")
+    else()
+        target_link_libraries(testgl "GL")
+    endif()
 endif()
 
 install(TARGETS SDL