default value of LIBA_CXX is set to 1
[liba.git] / cmake / Languages.cmake
blob811f3241cf4c525c2688772854b38b5977d91f70
1 set(CMAKE_EXPORT_COMPILE_COMMANDS 1 CACHE BOOL "Enable/Disable output of compile commands during generation.")
2 mark_as_advanced(CMAKE_EXPORT_COMPILE_COMMANDS)
3 if(NOT DEFINED CACHE{LIBA_CXX})
4   option(LIBA_CXX "Enable/Disable C++" 1)
5 endif()
6 list(FIND LANGUAGES CXX index)
7 if(${index} EQUAL -1 AND LIBA_CXX)
8   list(INSERT LANGUAGES 0 CXX)
9 endif()
10 list(FIND LANGUAGES C index)
11 if(${index} EQUAL -1)
12   list(INSERT LANGUAGES 0 C)
13 endif()
14 # default C standard
15 if(NOT CMAKE_C_STANDARD)
16   set(CMAKE_C_STANDARD 11)
17 endif()
18 if(NOT CMAKE_C_EXTENSIONS)
19   set(CMAKE_C_EXTENSIONS 0)
20 endif()
21 if(NOT CMAKE_C_STANDARD_REQUIRED)
22   set(CMAKE_C_STANDARD_REQUIRED 0)
23 endif()
24 # default C++ standard
25 if(NOT CMAKE_CXX_STANDARD)
26   set(CMAKE_CXX_STANDARD 11)
27 endif()
28 if(NOT CMAKE_CXX_EXTENSIONS)
29   set(CMAKE_CXX_EXTENSIONS 0)
30 endif()
31 if(NOT CMAKE_CXX_STANDARD_REQUIRED)
32   set(CMAKE_CXX_STANDARD_REQUIRED 0)
33 endif()
34 if(CMAKE_C_COMPILER_ID MATCHES "TinyCC")
35   string(FIND CMAKE_C_FLAGS "-std=c${CMAKE_C_STANDARD}" index)
36   if(${index} EQUAL -1)
37     string(STRIP "${CMAKE_C_FLAGS} -std=c${CMAKE_C_STANDARD}" CMAKE_C_FLAGS)
38   endif()
39 endif()
40 set(index)