0031740: Configuration - recover support of Yacc and Lex generation
[occt.git] / adm / cmake / flex.cmake
CommitLineData
316d77d9 1# flex
2
3# execute FindFLEX script by "find_package (Flex)" is required to define FLEX_TARGET macro
4
fba34cf8 5# delete obsolete 3RDPARTY_FLEX_EXECUTABLE cache variable (not used anymore)
6unset (3RDPARTY_FLEX_EXECUTABLE CACHE)
316d77d9 7
fba34cf8 8# delete FLEX_EXECUTABLE cache variable if it is empty, otherwise find_package will fail
9# without reasonable diagnostic
10if (NOT FLEX_EXECUTABLE)
11 unset (FLEX_EXECUTABLE CACHE)
12endif()
316d77d9 13
fba34cf8 14# Add paths to 3rdparty subfolders containing name "flex" to CMAKE_PROGRAM_PATH variable to make
15# these paths searhed by find_package
16if (3RDPARTY_DIR)
17 file (GLOB FLEX_PATHS LIST_DIRECTORIES true "${3RDPARTY_DIR}/*flex*")
18 foreach (candidate_path ${FLEX_PATHS})
19 if (IS_DIRECTORY ${candidate_path})
20 list (APPEND CMAKE_PROGRAM_PATH ${candidate_path})
21 endif()
22 endforeach()
316d77d9 23endif()
fba34cf8 24
25find_package (FLEX 2.5.3)
316d77d9 26
fba34cf8 27if (NOT FLEX_FOUND OR NOT FLEX_EXECUTABLE OR NOT EXISTS "${FLEX_EXECUTABLE}")
28 list (APPEND 3RDPARTY_NOT_INCLUDED FLEX_EXECUTABLE)
316d77d9 29endif()