CMakeLists.txt 4.18 KB
Newer Older
1
2
3

#Build the actual code
add_subdirectory(attribute)
4
smtk_source_group(attribute)
5
6

add_subdirectory(model)
7
smtk_source_group(model)
8

Bob Obara's avatar
Bob Obara committed
9
10
11
add_subdirectory(util)
smtk_source_group(util)

12
13
14
15
16
add_subdirectory(view)
smtk_source_group(view)

set(smtk_headers ${attributeHeaders} ${modelHeaders} ${utilHeaders} ${viewHeaders})
set(smtk_srcs ${attributeSrcs} ${modelSrcs} ${utilSrcs} ${viewSrcs})
17

18
add_library(SMTKCore ${smtk_srcs})
19
target_link_libraries(SMTKCore LINK_PRIVATE cJSON)
20
smtk_export_header(SMTKCore SMTKCoreExports.h)
21
22
23
24
if (NOT BUILD_SHARED_LIBS AND SMTK_BUILD_PYTHON_WRAPPINGS)
  # Set position-independent flag when other project libs are shared.
  set_target_properties(SMTKCore PROPERTIES POSITION_INDEPENDENT_CODE True)
endif()
25

26
#install the library and exports the library when used from a build tree
27
smtk_install_library(SMTKCore DEPENDS cJSON)
28

29
30
31
32
33
#add the Qt GUI code
if(SMTK_BUILD_QT)

  add_subdirectory(Qt)

34
  #we should at some point roll this into smtk_source_group
35
  get_directory_property(QAttrLibSrcs DIRECTORY Qt DEFINITION QAttrLibSrcs)
36
  smtk_prepend_string("Qt" QAttrLibSrcs ${QAttrLibSrcs})
37
38
  get_directory_property(QAttrLibHeaders DIRECTORY Qt DEFINITION QAttrLibHeaders)
  smtk_prepend_string("Qt" QAttrLibHeaders ${QAttrLibHeaders})
39
  get_directory_property(QAttrLibUIs DIRECTORY Qt DEFINITION QAttrLibUIs)
40
  smtk_prepend_string("Qt" QAttrLibUIs ${QAttrLibUIs})
41

42
43
44
45
46
  qt4_wrap_ui(UI_BUILT_SOURCES ${QAttrLibUIs})

  source_group("Qt_Source" FILES ${QAttrLibSrcs} ${QAttrLibUIs})
  source_group("Qt_Generated" FILES ${QAttrLibMocSrcs} ${UI_BUILT_SOURCES})
  source_group("Qt_Header" FILES ${QAttrLibMocHeaders})
47

48
  set(qtsmtk_headers ${QAttrLibHeaders})
49
  set(qtsmtk_srcs
50
51
52
53
   ${QAttrLibSrcs}
   ${UI_BUILT_SOURCES}
   )

54
  add_library(QtSMTK ${qtsmtk_srcs})
55
56
57
58

  #let cmake do what qt4_wrap_cpp used to do automatically
  set_target_properties(QtSMTK PROPERTIES AUTOMOC TRUE)

59
60
61
62
63
64
65
  #we need to add the location of the moc files to the include dir for
  #qtsmtk
  set_property(TARGET QtSMTK
               APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR})

  #set QtSMTK to link to qtGUI and include dirs
  qt4_use_modules(QtSMTK LINK_PUBLIC Gui)
66

67
68
  #set QtSMTK to publicly link to SMTKCore
  target_link_libraries(QtSMTK LINK_PUBLIC SMTKCore)
69
  smtk_export_header(QtSMTK QtSMTKExports.h)
70

71
72
  #install the library and exports the library when used from a build tree
  smtk_install_library(QtSMTK DEPENDS SMTKCore)
73

74
endif()
75

76
77
install(FILES PublicPointerDefs.h DESTINATION include/smtk)

78
79
#setup the exports for the library when used from an installed location
install(EXPORT SMTK-targets DESTINATION lib)
80
81
82
83
84
85
86
87
88

#wrap everything
if(SMTK_BUILD_PYTHON_WRAPPINGS AND Shiboken_FOUND)
  sbk_wrap_library(SMTKCore
    GENERATOR_ARGS --avoid-protected-hack
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    LOCAL_INCLUDE_DIRECTORIES
      ${CMAKE_CURRENT_SOURCE_DIR}/attribute
      ${CMAKE_CURRENT_SOURCE_DIR}/model
89
      ${CMAKE_CURRENT_SOURCE_DIR}/util
Bob Obara's avatar
Bob Obara committed
90
      ${CMAKE_CURRENT_SOURCE_DIR}/view
91
92
93
94
95
      ${CMAKE_CURRENT_SOURCE_DIR}
      ${CMAKE_CURRENT_BINARY_DIR}
    TYPESYSTEM typesystem.xml
    HEADERS ${smtk_headers}
  )
96

97
98
  #get the location to copy the shiboken library so developers have an
  #easier time testing the python wrapping
99

100
101
102
103
  #first we have to resolve the path since shiboken library most likely
  #uses symlinks and we have to copy that version
  get_filename_component(shiboken_path "${SHIBOKEN_LIBRARY}" REALPATH)
  file(COPY "${shiboken_path}" DESTINATION "${SMTK_BINARY_DIR}")
104

105
106
  configure_file("${CMAKE_CURRENT_SOURCE_DIR}/smtk.py"
                 "${SMTK_BINARY_DIR}/smtk.py" @ONLY)
107

108
109
110
  if(SMTK_ENABLE_TESTING)
    get_filename_component(SHIBOKEN_LIBRARY_PATH ${SHIBOKEN_LIBRARY} PATH)
    add_subdirectory(attribute/PythonTesting)
111
    add_subdirectory(model/PythonTesting)
Bob Obara's avatar
Bob Obara committed
112
    add_subdirectory(view/PythonTesting)
113
114
  endif(SMTK_ENABLE_TESTING)

115
116
117
  #todo we need to install this file in such a way that it can resolve
  #the location of shiboken, which is going to mean running fixup bundle
  #on the mac, and than fixing up the smtk.py package script
118
119

  install(CODE "set(LIBRARY_OUTPUT_PATH \"${CMAKE_INSTALL_PREFIX}/lib\")
Jacob Becker's avatar
Jacob Becker committed
120
                configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/smtk.py ${CMAKE_INSTALL_PREFIX}/python/smtk.py )" )
121
endif()