diff options
Diffstat (limited to 'Tests/X11')
-rw-r--r-- | Tests/X11/CMakeLists.txt | 48 | ||||
-rw-r--r-- | Tests/X11/HelloWorldX11.cxx | 22 |
2 files changed, 35 insertions, 35 deletions
diff --git a/Tests/X11/CMakeLists.txt b/Tests/X11/CMakeLists.txt index 03aa09578..76ae58c74 100644 --- a/Tests/X11/CMakeLists.txt +++ b/Tests/X11/CMakeLists.txt @@ -1,40 +1,40 @@ # a simple C only test case cmake_minimum_required (VERSION 2.6) -PROJECT (UseX11 CXX C) +project (UseX11 CXX C) -INCLUDE (${CMAKE_ROOT}/Modules/FindX11.cmake) -MESSAGE("X11_FOUND: ${X11_FOUND}") +include (${CMAKE_ROOT}/Modules/FindX11.cmake) +message("X11_FOUND: ${X11_FOUND}") -ADD_EXECUTABLE (UseX11 X11.c) +add_executable (UseX11 X11.c) install(TARGETS UseX11 DESTINATION bin) -# so for universal binaries this test will fail if -# -IF(APPLE) - LIST(LENGTH CMAKE_OSX_ARCHITECTURES NUMARCH) - IF(NUMARCH GREATER 1) - IF(NOT EXISTS /usr/X11R6/lib//libSM.6.dylib) - SET(X11_FOUND FALSE) - MESSAGE("disable X11, because of universal binary and sysroot") - ENDIF(NOT EXISTS /usr/X11R6/lib//libSM.6.dylib) - ENDIF(NUMARCH GREATER 1) -ENDIF(APPLE) +# so for universal binaries this test will fail if +# +if(APPLE) + list(LENGTH CMAKE_OSX_ARCHITECTURES NUMARCH) + if(NUMARCH GREATER 1) + if(NOT EXISTS /usr/X11R6/lib//libSM.6.dylib) + set(X11_FOUND FALSE) + message("disable X11, because of universal binary and sysroot") + endif() + endif() +endif() -IF(X11_FOUND) - ADD_DEFINITIONS(-DCMAKE_HAS_X) - INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(UseX11 ${X11_LIBRARIES}) - IF(APPLE) - ADD_EXECUTABLE(HelloWorldX11 HelloWorldX11.cxx) - TARGET_LINK_LIBRARIES(HelloWorldX11 ${X11_LIBRARIES}) +if(X11_FOUND) + add_definitions(-DCMAKE_HAS_X) + include_directories(${X11_INCLUDE_DIR}) + target_link_libraries(UseX11 ${X11_LIBRARIES}) + if(APPLE) + add_executable(HelloWorldX11 HelloWorldX11.cxx) + target_link_libraries(HelloWorldX11 ${X11_LIBRARIES}) install(TARGETS HelloWorldX11 DESTINATION bin) set(CPACK_BINARY_OSXX11 ON CACHE BOOL "" FORCE) set(CPACK_BINARY_PACKAGEMAKER OFF CACHE BOOL "" FORCE ) set(CPACK_PACKAGE_NAME HelloWorldX11Package) set(CPACK_PACKAGE_EXECUTABLES HelloWorldX11 HelloWorldX11) - ENDIF(APPLE) -ENDIF(X11_FOUND) + endif() +endif() # build a CPack driven installer package include(CPack) diff --git a/Tests/X11/HelloWorldX11.cxx b/Tests/X11/HelloWorldX11.cxx index e3c9dd9cf..f2b8bdd47 100644 --- a/Tests/X11/HelloWorldX11.cxx +++ b/Tests/X11/HelloWorldX11.cxx @@ -9,7 +9,7 @@ * Copyright (c) 2004 __MyCompanyName__. All rights reserved. * */ - + #ifndef MAIN_H #define MAIN_H 1 @@ -28,10 +28,10 @@ public: // constructor Main(int argc, char * const argv[]); //virtual ~Main(); - + private: - + /* here are our X variables */ Display *dis; @@ -53,7 +53,7 @@ private: /*** START MAIN.CPP ***/ -// modified from Brian Hammond's Howdy program at +// modified from Brian Hammond's Howdy program at // http://www.insanityengine.com/doc/x11/xintro.html // jeff louie 02.05.2004 @@ -73,11 +73,11 @@ Main::Main (int argc, char * const argv[]) { init_x(); // event loop - while(1) { + while(1) { // get the next event and stuff it into our event variable. // Note: only events we set the mask for are detected! XNextEvent(dis, &event); - + switch (event.type) { int x; @@ -115,19 +115,19 @@ Main::Main (int argc, char * const argv[]) { } } -void Main::init_x() { +void Main::init_x() { unsigned long black,white; dis=XOpenDisplay(NULL); screen=DefaultScreen(dis); black=BlackPixel(dis,screen), white=WhitePixel(dis, screen); - win=XCreateSimpleWindow(dis,DefaultRootWindow(dis),0,0, + win=XCreateSimpleWindow(dis,DefaultRootWindow(dis),0,0, 300, 300, 5,black, white); XSetStandardProperties(dis,win,"Hello World","Hi",None,NULL,0,NULL); XSelectInput(dis, win, ExposureMask|ButtonPressMask|KeyPressMask); // get Graphics Context - gc=XCreateGC(dis, win, 0,0); + gc=XCreateGC(dis, win, 0,0); XSetBackground(dis,gc,white); XSetForeground(dis,gc,black); XClearWindow(dis, win); @@ -137,8 +137,8 @@ void Main::init_x() { void Main::close_x() { XFreeGC(dis, gc); XDestroyWindow(dis,win); - XCloseDisplay(dis); - exit(1); + XCloseDisplay(dis); + exit(1); }; void Main::redraw() { |