File: CMakeLists.txt

package info (click to toggle)
qtbase-opensource-src 5.3.2%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 272,016 kB
  • sloc: cpp: 1,623,095; ansic: 386,069; xml: 101,194; sh: 16,504; python: 9,156; java: 4,681; asm: 4,531; perl: 2,392; yacc: 1,926; lex: 970; makefile: 498; awk: 142; objc: 70; sed: 3
file content (36 lines) | stat: -rw-r--r-- 1,037 bytes parent folder | download | duplicates (3)
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

cmake_minimum_required(VERSION 2.8.11)

project(test_interface)

find_package(Qt5Widgets)

set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

add_executable(test_interface_exe WIN32 main.cpp mainwindow.cpp)

# No need to specify include directories, compile definitions, the PIC flag, or to
# link explicitly to Qt5::WinMain.
target_link_libraries(test_interface_exe Qt5::Widgets)

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/try_compile-test.cpp"
    "
#include <QString>
#include <QWidget>

int main(int,char**) { QWidget w; w.show(); return 0; }
"
)

# The try_compile works because Qt5::Widgets is listed in the LINK_LIBRARIES,
# which causes the includes, defines and appropriate PIC flag to be used.
try_compile(_TRY_COMPILE_RES "${CMAKE_CURRENT_BINARY_DIR}/try_compile-test"
    "${CMAKE_CURRENT_BINARY_DIR}/try_compile-test.cpp"
    LINK_LIBRARIES Qt5::Widgets
    OUTPUT_VARIABLE TC_OV
)

if (NOT _TRY_COMPILE_RES)
    message(SEND_ERROR "The use of try_compile with Qt5::Widgets failed. The output was :\n${TC_OV}")
endif()