diff options
author | Brad King <brad.king@kitware.com> | 2016-12-02 19:34:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-12-02 20:11:49 (GMT) |
commit | 027ce359ff7454ac0aca4d9a9208759ef4b9c8b7 (patch) | |
tree | afdd06ef04418b23e20c39e522552bf778ed3ebb /Tests/FindOpenGL | |
parent | 738a182a90dd29ce16376ab03a08c718b8068867 (diff) | |
download | CMake-027ce359ff7454ac0aca4d9a9208759ef4b9c8b7.zip CMake-027ce359ff7454ac0aca4d9a9208759ef4b9c8b7.tar.gz CMake-027ce359ff7454ac0aca4d9a9208759ef4b9c8b7.tar.bz2 |
FindOpenGL: Provide imported targets for GL and GLU
Create OpenGL::GL and OpenGL::GLU imported targets using the locations
found.
This feature was originally added by commit v3.1.0-rc1~420^2~2
(FindOpenGL: Provide imported targets for GL and GLU, 2014-05-31) but
had to be reverted by commit v3.1.0-rc3~10^2 (FindOpenGL: Revert support
for imported targets, 2014-12-01) due to issue #15267. Since then we
added support for `IMPORTED_LIBNAME` to interface libraries, so use it
to handle the case where we have only the library name without an
absolute path.
Inspired-by: Philipp Möller <bootsarehax@googlemail.com>
Closes: #15267
Diffstat (limited to 'Tests/FindOpenGL')
-rw-r--r-- | Tests/FindOpenGL/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/FindOpenGL/Test/CMakeLists.txt | 14 | ||||
-rw-r--r-- | Tests/FindOpenGL/Test/main.c | 17 |
3 files changed, 41 insertions, 0 deletions
diff --git a/Tests/FindOpenGL/CMakeLists.txt b/Tests/FindOpenGL/CMakeLists.txt new file mode 100644 index 0000000..9aa3aba --- /dev/null +++ b/Tests/FindOpenGL/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindOpenGL.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindOpenGL/Test" + "${CMake_BINARY_DIR}/Tests/FindOpenGL/Test" + ${build_generator_args} + --build-project TestFindOpenGL + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindOpenGL/Test/CMakeLists.txt b/Tests/FindOpenGL/Test/CMakeLists.txt new file mode 100644 index 0000000..cac3424 --- /dev/null +++ b/Tests/FindOpenGL/Test/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.7) +project(TestFindOpenGL C) +include(CTest) + +find_package(OpenGL REQUIRED) + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt OpenGL::GLU) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${OPENGL_INGLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${OPENGL_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindOpenGL/Test/main.c b/Tests/FindOpenGL/Test/main.c new file mode 100644 index 0000000..bca3d7e --- /dev/null +++ b/Tests/FindOpenGL/Test/main.c @@ -0,0 +1,17 @@ +#ifdef _WIN32 +#include <windows.h> +#endif +#ifdef __APPLE__ +#include <OpenGL/gl.h> +#else +#include <GL/gl.h> +#endif + +#include <stdio.h> + +int main() +{ + /* Reference a GL symbol without requiring a context at runtime. */ + printf("&glGetString = %p\n", &glGetString); + return 0; +} |