1 1.1 christos include(CMakeLanguageInformation) 2 1.1 christos 3 1.1 christos set(CMAKE_ADA_OUTPUT_EXTENSION .o) 4 1.1 christos set(CMAKE_ADA_OUTPUT_EXTENSION_REPLACE TRUE) 5 1.1 christos 6 1.1 christos if(CMAKE_USER_MAKE_RULES_OVERRIDE) 7 1.1 christos include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override) 8 1.1 christos set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}") 9 1.1 christos endif(CMAKE_USER_MAKE_RULES_OVERRIDE) 10 1.1 christos 11 1.1 christos 12 1.1 christos if(CMAKE_USER_MAKE_RULES_OVERRIDE_ADA) 13 1.1 christos include(${CMAKE_USER_MAKE_RULES_OVERRIDE_ADA} RESULT_VARIABLE _override) 14 1.1 christos set(CMAKE_USER_MAKE_RULES_OVERRIDE_ADA "${_override}") 15 1.1 christos endif(CMAKE_USER_MAKE_RULES_OVERRIDE_ADA) 16 1.1 christos 17 1.1 christos set(CMAKE_ADA_FLAGS_INIT "$ENV{ADAFLAGS} ${CMAKE_ADA_FLAGS_INIT}") 18 1.1 christos 19 1.1 christos string(APPEND CMAKE_ADA_FLAGS_INIT " ") 20 1.1 christos string(APPEND CMAKE_ADA_FLAGS_DEBUG_INIT " -g") 21 1.1 christos string(APPEND CMAKE_ADA_FLAGS_MINSIZEREL_INIT " -Os") 22 1.1 christos string(APPEND CMAKE_ADA_FLAGS_RELEASE_INIT " -O3") 23 1.1 christos string(APPEND CMAKE_ADA_FLAGS_RELWITHDEBINFO_INIT " -O2 -g") 24 1.1 christos 25 1.1 christos cmake_initialize_per_config_variable(CMAKE_ADA_FLAGS "Flags used by the Ada compiler") 26 1.1 christos 27 1.1 christos if(CMAKE_ADA_STANDARD_LIBRARIES_INIT) 28 1.1 christos set(CMAKE_ADA_STANDARD_LIBRARIES 29 1.1 christos "${CMAKE_ADA_STANDARD_LIBRARIES_INIT}" 30 1.1 christos CACHE 31 1.1 christos STRING "Libraries linked by default with all Ada applications.") 32 1.1 christos mark_as_advanced(CMAKE_ADA_STANDARD_LIBRARIES) 33 1.1 christos endif(CMAKE_ADA_STANDARD_LIBRARIES_INIT) 34 1.1 christos 35 1.1 christos if(NOT CMAKE_ADA_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_ADA_COMPILER_LAUNCHER}) 36 1.1 christos set(CMAKE_ADA_COMPILER_LAUNCHER 37 1.1 christos "$ENV{CMAKE_ADA_COMPILER_LAUNCHER}" 38 1.1 christos CACHE 39 1.1 christos STRING "Compiler launcher for Ada.") 40 1.1 christos endif(NOT CMAKE_ADA_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_ADA_COMPILER_LAUNCHER}) 41 1.1 christos 42 1.1 christos if(NOT CMAKE_ADA_LINKER_LAUNCHER AND DEFINED ENV{CMAKE_ADA_LINKER_LAUNCHER}) 43 1.1 christos set(CMAKE_ADA_LINKER_LAUNCHER 44 1.1 christos "$ENV{CMAKE_ADA_LINKER_LAUNCHER}" 45 1.1 christos CACHE 46 1.1 christos STRING "Linker launcher for Ada.") 47 1.1 christos endif(NOT CMAKE_ADA_LINKER_LAUNCHER AND DEFINED ENV{CMAKE_ADA_LINKER_LAUNCHER}) 48 1.1 christos 49 1.1 christos include(CMakeCommonLanguageInclude) 50 1.1 christos _cmake_common_language_platform_flags(ADA) 51 1.1 christos 52 1.1 christos if(NOT CMAKE_ADA_CREATE_SHARED_LIBRARY) 53 1.1 christos set(CMAKE_ADA_CREATE_SHARED_LIBRARY 54 1.1 christos "${CMAKE_ADA_BINDER_HELPER} <CMAKE_ADA_COMPILER> <OBJECTS> FLAGS <FLAGS> <LINK_FLAGS>" 55 1.1 christos "${CMAKE_ADA_SHARED_LINK_HELPER} <CMAKE_ADA_COMPILER> <TARGET> <OBJECTS> <LINK_LIBRARIES>") 56 1.1 christos endif(NOT CMAKE_ADA_CREATE_SHARED_LIBRARY) 57 1.1 christos 58 1.1 christos if(NOT CMAKE_ADA_CREATE_STATIC_LIBRARY) 59 1.1 christos set(CMAKE_ADA_CREATE_STATIC_LIBRARY 60 1.1 christos "${CMAKE_ADA_STATIC_LINK_HELPER} ${CMAKE_AR} <TARGET> <OBJECTS>") 61 1.1 christos endif(NOT CMAKE_ADA_CREATE_STATIC_LIBRARY) 62 1.1 christos 63 1.1 christos if(NOT CMAKE_ADA_COMPILE_OBJECT) 64 1.1 christos set(CMAKE_ADA_COMPILE_OBJECT 65 1.1 christos "${CMAKE_ADA_COMPILER_HELPER} <CMAKE_ADA_COMPILER> <OBJECT_DIR> <SOURCE> <FLAGS>") 66 1.1 christos endif(NOT CMAKE_ADA_COMPILE_OBJECT) 67 1.1 christos 68 1.1 christos if(NOT CMAKE_ADA_LINK_EXECUTABLE) 69 1.1 christos set(CMAKE_ADA_LINK_EXECUTABLE 70 1.1 christos "${CMAKE_ADA_BINDER_HELPER} <CMAKE_ADA_COMPILER> <OBJECTS> FLAGS <FLAGS> <LINK_FLAGS>" 71 1.1 christos "${CMAKE_ADA_EXE_LINK_HELPER} <CMAKE_ADA_COMPILER> <TARGET> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> OBJ <OBJECTS> LIBS <LINK_LIBRARIES>") 72 1.1 christos endif(NOT CMAKE_ADA_LINK_EXECUTABLE) 73 1.1 christos 74 1.1 christos function(ada_add_executable) 75 1.1 christos if(ARGC GREATER 1) 76 1.1 christos math(EXPR last_index "${ARGC} - 1") 77 1.1 christos foreach(source RANGE 1 ${last_index}) 78 1.1 christos list(APPEND SOURCES ${ARGV${source}}) 79 1.1 christos string(REPLACE ".adb" "" ali "${ARGV${source}}") 80 1.1 christos set(clean_file "CMakeFiles/${ARGV0}.dir/${ali}.ali") 81 1.1 christos list(APPEND CLEAN_FILES ${clean_file}) 82 1.1 christos list(APPEND CLEAN_FILES b~${ali}.adb) 83 1.1 christos list(APPEND CLEAN_FILES b~${ali}.ads) 84 1.1 christos list(APPEND CLEAN_FILES b~${ali}.ali) 85 1.1 christos list(APPEND CLEAN_FILES b~${ali}.o) 86 1.1 christos endforeach(source RANGE 1 ${ARGC}) 87 1.1 christos 88 1.1 christos add_executable(${ARGV0} ${ARGV1} ${SOURCES}) 89 1.1 christos 90 1.1 christos set_target_properties(${ARGV0} 91 1.1 christos PROPERTIES 92 1.1 christos ADDITIONAL_CLEAN_FILES "${CLEAN_FILES}") 93 1.1 christos endif(ARGC GREATER 1) 94 1.1 christos endfunction(ada_add_executable) 95 1.1 christos 96 1.1 christos function(ada_add_library) 97 1.1 christos if(ARGC GREATER 2) 98 1.1 christos math(EXPR last_index "${ARGC} - 1") 99 1.1 christos foreach(source RANGE 2 ${last_index}) 100 1.1 christos list(APPEND SOURCES ${ARGV${source}}) 101 1.1 christos string(REPLACE ".adb" "" ali "${ARGV${source}}") 102 1.1 christos set(clean_file "CMakeFiles/${ARGV0}.dir/${ali}.ali") 103 1.1 christos list(APPEND CLEAN_FILES ${clean_file}) 104 1.1 christos list(APPEND CLEAN_FILES b~${ali}.adb) 105 1.1 christos list(APPEND CLEAN_FILES b~${ali}.ads) 106 1.1 christos list(APPEND CLEAN_FILES b~${ali}.ali) 107 1.1 christos list(APPEND CLEAN_FILES b~${ali}.o) 108 1.1 christos endforeach(source RANGE 2 ${ARGC}) 109 1.1 christos 110 1.1 christos add_library(${ARGV0} ${ARGV1} ${SOURCES}) 111 1.1 christos 112 1.1 christos set_target_properties(${ARGV0} 113 1.1 christos PROPERTIES 114 1.1 christos ADDITIONAL_CLEAN_FILES "${CLEAN_FILES};dummylib.adb;dummylib.ali;dummylib.o" 115 1.1 christos ALI_FLAG "-aO${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${ARGV0}.dir/") 116 1.1 christos endif(ARGC GREATER 2) 117 1.1 christos endfunction(ada_add_library) 118 1.1 christos 119 1.1 christos function(ada_find_ali) 120 1.1 christos get_target_property(link_libs ${ARGV0} LINK_LIBRARIES) 121 1.1 christos 122 1.1 christos foreach(lib IN LISTS link_libs) 123 1.1 christos get_target_property(ali ${lib} ALI_FLAG) 124 1.1 christos string(APPEND FLAGS ${ali} " ") 125 1.1 christos unset(ali) 126 1.1 christos endforeach(lib IN LISTS link_libs) 127 1.1 christos 128 1.1 christos set_target_properties(${ARGV0} 129 1.1 christos PROPERTIES 130 1.1 christos LINK_FLAGS ${FLAGS}) 131 1.1 christos endfunction(ada_find_ali) 132 1.1 christos 133 1.1 christos set(CMAKE_ADA_INFORMATION_LOADED TRUE) 134