0026460: Implicit cast to TopoDS_Shape compilation error due to ambiguous conversion
[occt.git] / adm / cmake / BuildToolkit.cmake
CommitLineData
19286d7c 1# Get all used packages from toolkit
2foreach (MODULE ${TOOLKIT_MODULES})
3 if (WIN32)
4 list (APPEND PRECOMPILED_DEFS "-D__${MODULE}_DLL")
5 endif()
6 list (APPEND COMPILER_DIRECTORIES "${OCCT_SOURCE_DIR}/src/${MODULE}")
7endforeach()
8string (REGEX REPLACE ";" " " PRECOMPILED_DEFS "${PRECOMPILED_DEFS}")
9
10# Get from toolkits EXTERNLIB all used libs
11OCCT_TOOLKIT_DEP (${PROJECT_NAME} ${PROJECT_NAME}_DEPS)
12foreach (DEP ${${PROJECT_NAME}_DEPS})
13 IS_OCCT_TOOLKIT (${DEP} OCCT_MODULES FOUND_TOOLKIT)
14 if ("${FOUND_TOOLKIT}" STREQUAL "ON")
15 list ( APPEND USED_LIBS "${DEP}" )
16 endif()
17endforeach()
18
19# Get all source files from used packages
20foreach (CDIR ${COMPILER_DIRECTORIES})
21 get_filename_component (CDirName ${CDIR} NAME)
22 set (CDIR_files)
d7b60a9f 23 set (HDIR_files)
24 file(STRINGS "${CDIR}/FILES" FLEX_Files REGEX ".+[.]lex")
25 file(STRINGS "${CDIR}/FILES" BISON_Files REGEX ".+[.]yacc")
26 file(STRINGS "${CDIR}/FILES" CFiles REGEX ".+[.]c")
27 file(STRINGS "${CDIR}/FILES" MFiles REGEX ".+[.]mm")
28 file(STRINGS "${CDIR}/FILES" HFiles REGEX ".+[.]h")
29 file(STRINGS "${CDIR}/FILES" LXXFiles REGEX ".+[.]lxx")
30 file(STRINGS "${CDIR}/FILES" GXXFiles REGEX ".+[.]gxx")
19286d7c 31
32 # Generate Flex and Bison files
33 if (${BUILD_BISON_FLEX_FILES})
34 list (LENGTH FLEX_Files FLength)
35 list (LENGTH BISON_Files BLength)
36 list (SORT FLEX_Files)
37 list (SORT BISON_Files)
38 if (${FLength} EQUAL ${BLength} AND NOT ${FLength} EQUAL 0)
39 math (EXPR FLength "${FLength} - 1")
40 foreach (FileIndex RANGE ${FLength})
41 list (GET FLEX_Files ${FileIndex} FLEX_File)
42 list (GET BISON_Files ${FileIndex} BISON_File)
43 get_filename_component (FLEX_Name ${FLEX_File} NAME_WE)
44 get_filename_component (BISON_Name ${BISON_File} NAME_WE)
45 string (COMPARE EQUAL ${FLEX_Name} ${BISON_Name} isEQUAL)
46 if (EXISTS "${FLEX_File}" AND EXISTS "${BISON_File}" AND ${isEQUAL})
47 BISON_TARGET (Parser_${BISON_Name} ${BISON_File} ${CDIR}/${BISON_Name}.tab.c)
48 FLEX_TARGET (Scanner_${FLEX_Name} ${FLEX_File} ${CDIR}/lex.${FLEX_Name}.c)
49 ADD_FLEX_BISON_DEPENDENCY (Scanner_${FLEX_Name} Parser_${BISON_Name})
50 list (APPEND CDIR_files ${BISON_Parser_${BISON_Name}_OUTPUTS} ${FLEX_Scanner_${FLEX_Name}_OUTPUTS})
51 endif()
52 endforeach()
53 endif()
54 endif()
55
d7b60a9f 56 list(APPEND HDIR_files ${HFiles} ${LXXFiles} ${GXXFiles})
57 list( APPEND CDIR_files ${CFiles})
58 if(APPLE)
59 list( APPEND CDIR_files ${MFiles})
19286d7c 60 endif()
61
d7b60a9f 62 foreach(HFile ${HDIR_files})
63 list( APPEND USED_INCFILES ${CDIR}/${HFile} )
64 SOURCE_GROUP ("Header Files\\${CDirName}" FILES ${CDIR}/${HFile})
65 endforeach(HFile)
19286d7c 66
d7b60a9f 67 foreach(CFile ${CDIR_files})
68 list( APPEND USED_SRCFILES ${CDIR}/${CFile} )
69 SOURCE_GROUP ("Source Files\\${CDirName}" FILES ${CDIR}/${CFile})
70 endforeach(CFile)
71endforeach(CDIR)
19286d7c 72
d7b60a9f 73list( FIND USED_TOOLKITS ${PROJECT_NAME} isFOUND)
19286d7c 74
75# Create project for toolkit
76if ("${USED_TOOLKITS}" STREQUAL "" OR NOT ${isFOUND} EQUAL -1)
77 foreach (MODULE ${OCCT_MODULES})
78 list (FIND ${MODULE}_TOOLKITS ${PROJECT_NAME} isFOUND)
79 if (NOT ${isFOUND} EQUAL -1)
80 set (CURRENT_MODULE ${MODULE})
81 endif()
82 endforeach()
83 if (isEXE)
d7b60a9f 84 add_executable (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES})
fa0cbe55 85 install (TARGETS ${PROJECT_NAME}
86 CONFIGURATIONS Release
87 DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
88 install (TARGETS ${PROJECT_NAME}
89 CONFIGURATIONS RelWithDebInfo
90 DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
91 install (TARGETS ${PROJECT_NAME}
92 CONFIGURATIONS Debug
93 DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
19286d7c 94 else()
d7b60a9f 95 add_library (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES})
19286d7c 96 install (TARGETS ${PROJECT_NAME}
fa0cbe55 97 CONFIGURATIONS Release
98 RUNTIME DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin"
99 ARCHIVE DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib"
100 LIBRARY DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
101 install (TARGETS ${PROJECT_NAME}
102 CONFIGURATIONS RelWithDebInfo
103 RUNTIME DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin"
104 ARCHIVE DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib"
105 LIBRARY DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
106 install (TARGETS ${PROJECT_NAME}
107 CONFIGURATIONS Debug
108 RUNTIME DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bind"
109 ARCHIVE DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/libd"
110 LIBRARY DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
19286d7c 111 if (MSVC)
fa0cbe55 112 install (FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind/${PROJECT_NAME}.pdb
19286d7c 113 CONFIGURATIONS Debug
fa0cbe55 114 DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
19286d7c 115 endif()
116 endif()
117
118 set_property (TARGET ${PROJECT_NAME} PROPERTY FOLDER "Modules/${CURRENT_MODULE}")
119 set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}")
19286d7c 120 target_link_libraries (${PROJECT_NAME} ${USED_LIBS})
121endif()