0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / adm / cmake / flex.cmake
1 # flex
2
3 # execute FindFLEX script by "find_package (Flex)" is required to define FLEX_TARGET macro
4
5 # delete obsolete 3RDPARTY_FLEX_EXECUTABLE cache variable (not used anymore)
6 unset (3RDPARTY_FLEX_EXECUTABLE CACHE)
7
8 # delete FLEX_EXECUTABLE cache variable if it is empty, otherwise find_package will fail
9 # without reasonable diagnostic
10 if (NOT FLEX_EXECUTABLE OR NOT EXISTS "${FLEX_EXECUTABLE}")
11   unset (FLEX_EXECUTABLE CACHE)
12 endif()
13 if (NOT FLEX_INCLUDE_DIR OR NOT EXISTS "${FLEX_INCLUDE_DIR}")
14   unset (FLEX_INCLUDE_DIR CACHE)
15 endif()
16
17 # Add paths to 3rdparty subfolders containing name "flex" to CMAKE_PROGRAM_PATH and 
18 # CMAKE_INCLUDE_PATH variables to make these paths searhed by find_package
19 if (3RDPARTY_DIR)
20   file (GLOB FLEX_PATHS LIST_DIRECTORIES true "${3RDPARTY_DIR}/*flex*")
21   foreach (candidate_path ${FLEX_PATHS})
22     if (IS_DIRECTORY ${candidate_path})
23       list (APPEND CMAKE_PROGRAM_PATH ${candidate_path})
24       list (APPEND CMAKE_INCLUDE_PATH ${candidate_path})
25     endif()
26   endforeach()
27 endif()
28  
29 # flex 2.5.37 is required because closest known lower version, 2.5.3 from WOK 6.8.0,
30 # generates code which is unusable on Windows (includes unistd.h without any way to avoid this)
31 find_package (FLEX 2.5.37)
32
33 if (NOT FLEX_FOUND OR NOT FLEX_INCLUDE_DIR OR NOT EXISTS "${FLEX_INCLUDE_DIR}/FlexLexer.h")
34   list (APPEND 3RDPARTY_NOT_INCLUDED FLEX_INCLUDE_DIR)
35 endif()