Updated formatting of documentation plus a little reorganization.
[cmake.git] / Tests / X11 / CMakeLists.txt
blob03aa09578c5074fad0f473c07045941e23b45cb2
1 # a simple C only test case
2 cmake_minimum_required (VERSION 2.6)
3 PROJECT (UseX11 CXX C)
5 INCLUDE (${CMAKE_ROOT}/Modules/FindX11.cmake)
6 MESSAGE("X11_FOUND: ${X11_FOUND}")
8 ADD_EXECUTABLE (UseX11 X11.c)
9 install(TARGETS UseX11 DESTINATION bin)
11 # so for universal binaries this test will fail if 
12
13 IF(APPLE)
14   LIST(LENGTH CMAKE_OSX_ARCHITECTURES NUMARCH)
15   IF(NUMARCH GREATER 1)
16     IF(NOT EXISTS /usr/X11R6/lib//libSM.6.dylib)
17       SET(X11_FOUND FALSE)
18       MESSAGE("disable X11, because of universal binary and sysroot")
19     ENDIF(NOT EXISTS /usr/X11R6/lib//libSM.6.dylib)
20   ENDIF(NUMARCH GREATER 1)
21 ENDIF(APPLE)
23 IF(X11_FOUND)
24   ADD_DEFINITIONS(-DCMAKE_HAS_X)
25   INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR})
26   TARGET_LINK_LIBRARIES(UseX11 ${X11_LIBRARIES})
27   IF(APPLE)
28     ADD_EXECUTABLE(HelloWorldX11 HelloWorldX11.cxx)
29     TARGET_LINK_LIBRARIES(HelloWorldX11 ${X11_LIBRARIES})
30     install(TARGETS HelloWorldX11 DESTINATION bin)
32     set(CPACK_BINARY_OSXX11 ON CACHE BOOL "" FORCE)
33     set(CPACK_BINARY_PACKAGEMAKER OFF CACHE BOOL "" FORCE )
34     set(CPACK_PACKAGE_NAME HelloWorldX11Package)
35     set(CPACK_PACKAGE_EXECUTABLES HelloWorldX11 HelloWorldX11)
36   ENDIF(APPLE)
37 ENDIF(X11_FOUND)
39 # build a CPack driven installer package
40 include(CPack)