-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmafMacroInitProject.cmake
72 lines (63 loc) · 2.19 KB
/
mafMacroInitProject.cmake
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#
# mafMacroInitProject.cmake
# maf
#
# Created by Daniele Giunchi - Paolo Quadrani on 10/09/10.
# Copyright 2009 B3C. All rights reserved.
#
# See Licence at: http://tiny.cc/QXJ4D
#
#
MACRO(mafMacroInitProject test)
# Extract current directory name to use as project name
file(GLOB CUR_FILE "CMakeLists.txt")
get_filename_component(CUR_ABSOLUTE_DIR ${CUR_FILE} PATH)
get_filename_component(DIR_NAME ${CUR_ABSOLUTE_DIR} NAME)
PROJECT(${DIR_NAME})
FILE(GLOB include_file_list "${PROJECT_SOURCE_DIR}/*.h")
FILE(GLOB implementation_file_list "${PROJECT_SOURCE_DIR}/*.cpp")
FILE(GLOB templete_file_list1 "${PROJECT_SOURCE_DIR}/*.txx")
FILE(GLOB templete_file_list2 "${PROJECT_SOURCE_DIR}/*.tpp")
FILE(GLOB resource_file_list "${PROJECT_SOURCE_DIR}/*.qrc")
FILE(GLOB ui_file_list "${PROJECT_SOURCE_DIR}/*.ui")
# Set your list of sources here.
SET(PROJECT_SRCS
${implementation_file_list}
${include_file_list}
${templete_file_list1}
${templete_file_list2}
${ui_file_list}
${resource_file_list}
)
## Add the project binary dir as include dir for the .moc files.
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
set(MY_MOC_CXX )
if(${test})
## Moc the tests:
foreach(FILE_NAME_ABS ${implementation_file_list})
## extract the base file name.
get_filename_component(FILE_NAME ${FILE_NAME_ABS} NAME_WE)
## Exclude the main.cpp file (it doesn't ned to be 'mocced')
if(NOT ${FILE_NAME} STREQUAL "main")
## Assign the moc custom filename
set(MOC_FILE "${FILE_NAME}.moc")
QT4_GENERATE_MOC(${FILE_NAME_ABS} ${MOC_FILE})
LIST(APPEND MY_MOC_CXX "${PROJECT_BINARY_DIR}/${MOC_FILE}")
endif(NOT ${FILE_NAME} STREQUAL "main")
endforeach()
else(${test})
## Moc the library's .h files
QT4_WRAP_CPP(MY_MOC_CXX ${include_file_list})
QT4_WRAP_UI(MY_UI_CXX ${ui_file_list})
#QT4_ADD_RESOURCES(MY_RESOURCE_CXX ${resource_file_list})
endif(${test})
SET(PROJECT_SRCS
${PROJECT_SRCS}
${MY_MOC_CXX}
${MY_UI_CXX}
${resource_file_list}
)
# List libraries that are needed by this project.
mafMacroGetTargetLibraries(dependency_libraries)
SET(PROJECT_LIBS ${dependency_libraries})
ENDMACRO()