File: CMakeLists.txt

package info (click to toggle)
cmake 4.2.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 152,456 kB
  • sloc: ansic: 403,896; cpp: 303,920; sh: 4,105; python: 3,583; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 111; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (45 lines) | stat: -rw-r--r-- 1,734 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45


if(UNIX  AND  "${CMAKE_GENERATOR}" MATCHES "Makefile" AND
    NOT CMake_TEST_NO_FindPackageModeMakefileTest)

  # Test whether the make is GNU make, and only add the test in this case,
  # since the configured makefile in this test uses $(shell ...), which
  # is AFAIK a GNU make extension. Alex
  execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} -v
                  OUTPUT_VARIABLE makeVersionOutput
                  ERROR_QUIET
                  TIMEOUT 10)
  string(TOUPPER "${makeVersionOutput}" MAKE_VERSION_OUTPUT)
  if("${MAKE_VERSION_OUTPUT}" MATCHES "GNU MAKE")

    # build a library which we can search during the test
    add_library(foo STATIC foo.cpp)

    # configure a FindFoo.cmake so it knows where the library can be found
    configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY)

    set(EXTRA_FLAGS "")
    if(APPLE)
      # Need the -isysroot flag on recentish macOS after command line tools
      # no longer provide headers in /usr/include
      if(CMAKE_OSX_SYSROOT)
        string(APPEND EXTRA_FLAGS " -isysroot ${CMAKE_OSX_SYSROOT}")
      endif()
      foreach(arch ${CMAKE_OSX_ARCHITECTURES})
        string(APPEND EXTRA_FLAGS " -arch ${arch}")
      endforeach()
    endif()

    # now set up the test:
    file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk"
      CONTENT "CMAKE = \"$<TARGET_FILE:cmake>\"\n"
    )
    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY)
    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY)

    add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile )

  endif()

endif()