0029684: Configuration: modification of build Inspector tool standalone on occt
[occt.git] / samples / tools / TStandalone / adm / cmake / occt_toolkit_standalone.cmake
1 # script for each OCCT toolkit
2
3 #Qt dependencies
4 #message ("Project is ${PROJECT_NAME}")
5 if (EXECUTABLE_PROJECT)
6   set (PACKAGE_PREFIX_DIR "samples/tools")
7   SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/../${PROJECT_NAME})
8   include_directories("${SOURCE_DIR}")
9   #message("Inc dir: ${CMAKE_SOURCE_DIR}/../${PROJECT_NAME}")
10 else()
11   set (PACKAGE_PREFIX_DIR "tools")
12   SET(SOURCE_DIR ${CASROOT_SOURCE_FILES}/${PACKAGE_PREFIX_DIR}/${PROJECT_NAME})
13 endif()
14
15 FIND_SOURCES_AND_HEADERS_FILES(${SOURCE_DIR} SOURCE_FILES HEADER_FILES)
16
17 #message ("Source dir is ${SOURCE_DIR}")
18 #message ("Sources are ${SOURCE_FILES}")
19
20 unset(RCC_FILES)
21 if (USE_QT)
22   FIND_QT_PACKAGE(PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES)
23
24   FIND_AND_WRAP_MOC_FILES("${SOURCE_FILES}")
25   FIND_AND_WRAP_RESOURCE_FILE("${SOURCE_DIR}/${PROJECT_NAME}.qrc" RCC_FILES)
26
27 endif()
28
29 if (TOOLKIT_NAME)
30   set(TARGET_NAME TK${PROJECT_NAME})
31 else ()
32   set(TARGET_NAME ${PROJECT_NAME})
33 endif()
34
35 if (EXECUTABLE_PROJECT)
36   add_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
37 else()
38   add_library(${TARGET_NAME} SHARED ${SOURCE_FILES} ${HEADER_FILES})
39 endif()
40
41
42 include_directories(
43   ${PROJECT_INCLUDES}
44   ${SOURCE_DIR}
45   ${3RDPARTY_OCCT_INCLUDE_DIR}
46  "${CMAKE_BINARY_DIR}/inc")
47
48 add_definitions(-D__WIN32__)
49 add_definitions(-DWNT)
50 add_definitions(-D__${PROJECT_NAME}_DLL)
51
52 # parce EXTERNLIB file
53 FILE_TO_LIST ("src/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS)
54 foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS})
55   string (REGEX MATCH "^ *#" COMMENT_FOUND ${USED_ITEM})
56   if (NOT COMMENT_FOUND)
57     set (LIB_ITEM ${USED_ITEM})
58     set (LIB_PARSED_ITEM ${${USED_ITEM}})
59
60     if (LIB_PARSED_ITEM)
61       list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${${USED_ITEM}})
62       #message("Append external lib: ${${USED_ITEM}}")
63     else ()
64       list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${USED_ITEM})
65       #message("Append lib: ${USED_ITEM}")
66     endif()
67
68   endif()
69 endforeach()
70
71
72 target_link_libraries (${TARGET_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT})
73
74 if (USE_QT)
75   target_link_libraries (${TARGET_NAME} debug ${PROJECT_LIBRARIES_DEBUG})
76   target_link_libraries (${TARGET_NAME} optimized ${PROJECT_LIBRARIES_RELEASE})
77
78   if (NOT "${RCC_FILES}" STREQUAL "")
79     #message("RCC files: ${RCC_FILES}")
80     target_sources(${TARGET_NAME} PRIVATE ${RCC_FILES})
81   endif()
82 endif()
83
84 if (EXECUTABLE_PROJECT)
85   INSTALL(TARGETS ${TARGET_NAME} DESTINATION "${INSTALL_DIR_BIN}")
86 else()
87   if (MSVC)
88     install (DIRECTORY  ${PROJECT_BINARY_DIR}/Debug/
89              DESTINATION "${INSTALL_DIR_BIN}"
90              FILES_MATCHING PATTERN *.pdb)
91     if (INSTALL_API_DIR)
92       install (DIRECTORY  ${PROJECT_BINARY_DIR}/Debug/
93                DESTINATION "${INSTALL_API_DIR}/bin"
94                FILES_MATCHING PATTERN *.pdb)
95     endif()
96   endif()
97   install (TARGETS ${TARGET_NAME}
98            RUNTIME DESTINATION "${INSTALL_DIR_BIN}"
99            ARCHIVE DESTINATION "${INSTALL_DIR_LIB}"
100            LIBRARY DESTINATION "${INSTALL_DIR_LIB}")
101
102   if (INSTALL_API_DIR)
103     install (TARGETS ${TARGET_NAME}
104              RUNTIME DESTINATION "${INSTALL_API_DIR}/bin")
105
106     if (INSTALL_API)
107       INSTALL(FILES ${HEADER_FILES} DESTINATION "${INSTALL_API_DIR}/${INSTALL_DIR_INCLUDE}")
108     
109       install (DIRECTORY  ${PROJECT_BINARY_DIR}/Debug/
110                DESTINATION "${INSTALL_API_DIR}/lib"
111                FILES_MATCHING PATTERN *.lib)
112     endif()
113   endif()
114
115 endif()