├── crates ├── test-bin │ ├── .gitignore │ ├── src │ │ └── main.rs │ ├── Cargo.lock │ └── Cargo.toml ├── test-lib │ ├── .gitignore │ ├── CMakeLists.txt │ ├── Cargo.lock │ ├── src │ │ └── lib.rs │ └── Cargo.toml └── CMakeLists.txt ├── hello ├── hello.rs └── CMakeLists.txt ├── cmake ├── CMakeTestRustCompiler.cmake ├── CMakeRustCompiler.cmake.in ├── CMakeDetermineRustCompiler.cmake ├── FindRust.cmake ├── CMakeCargo.cmake ├── CargoLink.cmake └── CMakeRustInformation.cmake ├── hello_world ├── hello.c ├── test_lib.h └── CMakeLists.txt ├── .gitignore ├── CMakeLists.txt ├── .github └── CODEOWNERS ├── LICENSE-MIT └── LICENSE-APACHE /crates/test-bin/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /crates/test-lib/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /crates/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(test-lib) -------------------------------------------------------------------------------- /crates/test-lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cargo_build(NAME test-lib) 2 | -------------------------------------------------------------------------------- /hello/hello.rs: -------------------------------------------------------------------------------- 1 | 2 | fn main() { 3 | println!("Hello, World!"); 4 | } 5 | 6 | -------------------------------------------------------------------------------- /crates/test-bin/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, world!"); 3 | } 4 | -------------------------------------------------------------------------------- /crates/test-bin/Cargo.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "test-bin" 3 | version = "0.1.0" 4 | 5 | -------------------------------------------------------------------------------- /crates/test-lib/Cargo.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "test-lib" 3 | version = "0.1.0" 4 | 5 | -------------------------------------------------------------------------------- /cmake/CMakeTestRustCompiler.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(CMAKE_Rust_COMPILER_WORKS 1 CACHE INTERNAL "") 3 | 4 | -------------------------------------------------------------------------------- /hello_world/hello.c: -------------------------------------------------------------------------------- 1 | 2 | #include "test_lib.h" 3 | 4 | int main(int argc, char* argv[]) { 5 | hello(); 6 | } -------------------------------------------------------------------------------- /hello_world/test_lib.h: -------------------------------------------------------------------------------- 1 | #ifndef TEST_LIB 2 | #define TEST_LIB 3 | 4 | void hello(); 5 | 6 | #endif /* TEST_LIB */ -------------------------------------------------------------------------------- /crates/test-lib/src/lib.rs: -------------------------------------------------------------------------------- 1 | 2 | #[no_mangle] 3 | pub extern "C" fn hello() { 4 | println!("hello world!"); 5 | } -------------------------------------------------------------------------------- /hello/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_executable(hello hello.rs) 3 | 4 | set_target_properties(hello PROPERTIES LINKER_LANGUAGE Rust) 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *~ 3 | bin 4 | lib 5 | *.exe 6 | build 7 | Makefile 8 | CMakeFiles 9 | CMakeCache.txt 10 | cmake_install.cmake 11 | .vscode/ 12 | -------------------------------------------------------------------------------- /crates/test-bin/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "test-bin" 3 | version = "0.1.0" 4 | authors = ["Marc-André Moreau "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /crates/test-lib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "test-lib" 3 | version = "0.1.0" 4 | authors = ["Marc-André Moreau "] 5 | 6 | [lib] 7 | crate-type = ["staticlib"] 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(CMakeRust) 4 | 5 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") 6 | 7 | enable_language(Rust) 8 | include(CMakeCargo) 9 | 10 | add_subdirectory(hello_world) 11 | add_subdirectory(crates) 12 | 13 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # File auto-generated and managed by Devops 2 | /.github/workflows @devolutions/devops 3 | /.github/randy.yml @devolutions/devops 4 | /.github/CODEOWNERS @devolutions/devops 5 | /.github/scripts/ @devolutions/devops 6 | /.github/dependabot.yml @devolutions/security-managers 7 | -------------------------------------------------------------------------------- /hello_world/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_executable(helloworld hello.c) 3 | if(WIN32) 4 | target_link_libraries(helloworld test-lib ws2_32 userenv) 5 | elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") 6 | target_link_libraries(helloworld test-lib resolv) 7 | else() 8 | target_link_libraries(helloworld test-lib pthread dl m) 9 | endif() 10 | -------------------------------------------------------------------------------- /cmake/CMakeRustCompiler.cmake.in: -------------------------------------------------------------------------------- 1 | 2 | set(CMAKE_Rust_COMPILER "@CMAKE_Rust_COMPILER@") 3 | set(CMAKE_Rust_COMPILER_ID "@CMAKE_Rust_COMPILER_ID@") 4 | set(CMAKE_Rust_COMPILER_VERSION "@CMAKE_Rust_COMPILER_VERSION@") 5 | set(CMAKE_Rust_COMPILER_LOADED @CMAKE_Rust_COMPILER_LOADED@) 6 | set(CMAKE_Rust_PLATFORM_ID "@CMAKE_Rust_PLATFORM_ID@") 7 | 8 | SET(CMAKE_Rust_SOURCE_FILE_EXTENSIONS rs) 9 | SET(CMAKE_Rust_LINKER_PREFERENCE 40) 10 | #SET(CMAKE_Rust_OUTPUT_EXTENSION_REPLACE 1) 11 | SET(CMAKE_STATIC_LIBRARY_PREFIX_Rust "") 12 | SET(CMAKE_STATIC_LIBRARY_SUFFIX_Rust .a) 13 | 14 | set(CMAKE_Rust_COMPILER_ENV_VAR "RUSTC") 15 | 16 | -------------------------------------------------------------------------------- /cmake/CMakeDetermineRustCompiler.cmake: -------------------------------------------------------------------------------- 1 | 2 | if(NOT CMAKE_Rust_COMPILER) 3 | find_package(Rust) 4 | if(RUST_FOUND) 5 | set(CMAKE_Rust_COMPILER "${RUSTC_EXECUTABLE}") 6 | set(CMAKE_Rust_COMPILER_ID "Rust") 7 | set(CMAKE_Rust_COMPILER_VERSION "${RUST_VERSION}") 8 | set(CMAKE_Rust_PLATFORM_ID "Rust") 9 | endif() 10 | endif() 11 | 12 | message(STATUS "Cargo Home: ${CARGO_HOME}") 13 | message(STATUS "Rust Compiler Version: ${RUSTC_VERSION}") 14 | 15 | mark_as_advanced(CMAKE_Rust_COMPILER) 16 | 17 | if(CMAKE_Rust_COMPILER) 18 | set(CMAKE_Rust_COMPILER_LOADED 1) 19 | endif(CMAKE_Rust_COMPILER) 20 | 21 | configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeRustCompiler.cmake.in 22 | ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${CMAKE_VERSION}/CMakeRustCompiler.cmake IMMEDIATE @ONLY) 23 | 24 | set(CMAKE_Rust_COMPILER_ENV_VAR "RUSTC") 25 | 26 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /cmake/FindRust.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(_CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ${CMAKE_FIND_ROOT_PATH_MODE_PROGRAM}) 3 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) 4 | set(_CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ${CMAKE_FIND_ROOT_PATH_MODE_INCLUDE}) 5 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) 6 | 7 | if(CMAKE_HOST_WIN32) 8 | set(USER_HOME "$ENV{USERPROFILE}") 9 | else() 10 | set(USER_HOME "$ENV{HOME}") 11 | endif() 12 | 13 | if(NOT DEFINED CARGO_HOME) 14 | if("$ENV{CARGO_HOME}" STREQUAL "") 15 | set(CARGO_HOME "${USER_HOME}/.cargo") 16 | else() 17 | set(CARGO_HOME "$ENV{CARGO_HOME}") 18 | endif() 19 | endif() 20 | 21 | # Find cargo executable 22 | find_program(CARGO_EXECUTABLE cargo 23 | HINTS "${CARGO_HOME}" 24 | PATH_SUFFIXES "bin") 25 | mark_as_advanced(CARGO_EXECUTABLE) 26 | 27 | # Find rustc executable 28 | find_program(RUSTC_EXECUTABLE rustc 29 | HINTS "${CARGO_HOME}" 30 | PATH_SUFFIXES "bin") 31 | mark_as_advanced(RUSTC_EXECUTABLE) 32 | 33 | # Find rustdoc executable 34 | find_program(RUSTDOC_EXECUTABLE rustdoc 35 | HINTS "${CARGO_HOME}" 36 | PATH_SUFFIXES "bin") 37 | mark_as_advanced(RUSTDOC_EXECUTABLE) 38 | 39 | # Find rust-gdb executable 40 | find_program(RUST_GDB_EXECUTABLE rust-gdb 41 | HINTS "${CARGO_HOME}" 42 | PATH_SUFFIXES "bin") 43 | mark_as_advanced(RUST_GDB_EXECUTABLE) 44 | 45 | # Find rust-lldb executable 46 | find_program(RUST_LLDB_EXECUTABLE rust-lldb 47 | HINTS "${CARGO_HOME}" 48 | PATH_SUFFIXES "bin") 49 | mark_as_advanced(RUST_LLDB_EXECUTABLE) 50 | 51 | # Find rustup executable 52 | find_program(RUSTUP_EXECUTABLE rustup 53 | HINTS "${CARGO_HOME}" 54 | PATH_SUFFIXES "bin") 55 | mark_as_advanced(RUSTUP_EXECUTABLE) 56 | 57 | set(RUST_FOUND FALSE CACHE INTERNAL "") 58 | 59 | if(CARGO_EXECUTABLE AND RUSTC_EXECUTABLE AND RUSTDOC_EXECUTABLE) 60 | set(RUST_FOUND TRUE CACHE INTERNAL "") 61 | 62 | set(CARGO_HOME "${CARGO_HOME}" CACHE PATH "Rust Cargo Home") 63 | 64 | execute_process(COMMAND ${RUSTC_EXECUTABLE} --version OUTPUT_VARIABLE RUSTC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) 65 | string(REGEX REPLACE "rustc ([^ ]+) .*" "\\1" RUSTC_VERSION "${RUSTC_VERSION}") 66 | endif() 67 | 68 | if(NOT RUST_FOUND) 69 | message(FATAL_ERROR "Could not find Rust!") 70 | endif() 71 | 72 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ${_CMAKE_FIND_ROOT_PATH_MODE_PROGRAM}) 73 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ${_CMAKE_FIND_ROOT_PATH_MODE_INCLUDE}) 74 | -------------------------------------------------------------------------------- /cmake/CMakeCargo.cmake: -------------------------------------------------------------------------------- 1 | function(cargo_build) 2 | cmake_parse_arguments(CARGO "" "NAME" "" ${ARGN}) 3 | string(REPLACE "-" "_" LIB_NAME ${CARGO_NAME}) 4 | 5 | set(CARGO_TARGET_DIR ${CMAKE_CURRENT_BINARY_DIR}) 6 | 7 | if(WIN32) 8 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 9 | set(LIB_TARGET "x86_64-pc-windows-msvc") 10 | else() 11 | set(LIB_TARGET "i686-pc-windows-msvc") 12 | endif() 13 | elseif(ANDROID) 14 | if(ANDROID_SYSROOT_ABI STREQUAL "x86") 15 | set(LIB_TARGET "i686-linux-android") 16 | elseif(ANDROID_SYSROOT_ABI STREQUAL "x86_64") 17 | set(LIB_TARGET "x86_64-linux-android") 18 | elseif(ANDROID_SYSROOT_ABI STREQUAL "arm") 19 | set(LIB_TARGET "arm-linux-androideabi") 20 | elseif(ANDROID_SYSROOT_ABI STREQUAL "arm64") 21 | set(LIB_TARGET "aarch64-linux-android") 22 | endif() 23 | elseif(IOS) 24 | set(LIB_TARGET "universal") 25 | elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) 26 | set(LIB_TARGET "x86_64-apple-darwin") 27 | else() 28 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 29 | set(LIB_TARGET "x86_64-unknown-linux-gnu") 30 | else() 31 | set(LIB_TARGET "i686-unknown-linux-gnu") 32 | endif() 33 | endif() 34 | 35 | if(NOT CMAKE_BUILD_TYPE) 36 | set(LIB_BUILD_TYPE "debug") 37 | elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release") 38 | set(LIB_BUILD_TYPE "release") 39 | else() 40 | set(LIB_BUILD_TYPE "debug") 41 | endif() 42 | 43 | set(LIB_FILE "${CARGO_TARGET_DIR}/${LIB_TARGET}/${LIB_BUILD_TYPE}/${CMAKE_STATIC_LIBRARY_PREFIX}${LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}") 44 | 45 | if(IOS) 46 | set(CARGO_ARGS "lipo") 47 | else() 48 | set(CARGO_ARGS "build") 49 | list(APPEND CARGO_ARGS "--target" ${LIB_TARGET}) 50 | endif() 51 | 52 | if(${LIB_BUILD_TYPE} STREQUAL "release") 53 | list(APPEND CARGO_ARGS "--release") 54 | endif() 55 | 56 | file(GLOB_RECURSE LIB_SOURCES "*.rs") 57 | 58 | set(CARGO_ENV_COMMAND ${CMAKE_COMMAND} -E env "CARGO_TARGET_DIR=${CARGO_TARGET_DIR}") 59 | 60 | add_custom_command( 61 | OUTPUT ${LIB_FILE} 62 | COMMAND ${CARGO_ENV_COMMAND} ${CARGO_EXECUTABLE} ARGS ${CARGO_ARGS} 63 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 64 | DEPENDS ${LIB_SOURCES} 65 | COMMENT "running cargo") 66 | add_custom_target(${CARGO_NAME}_target ALL DEPENDS ${LIB_FILE}) 67 | add_library(${CARGO_NAME} STATIC IMPORTED GLOBAL) 68 | add_dependencies(${CARGO_NAME} ${CARGO_NAME}_target) 69 | set_target_properties(${CARGO_NAME} PROPERTIES IMPORTED_LOCATION ${LIB_FILE}) 70 | endfunction() -------------------------------------------------------------------------------- /cmake/CargoLink.cmake: -------------------------------------------------------------------------------- 1 | 2 | function(cargo_print) 3 | execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${ARGN}") 4 | endfunction() 5 | 6 | function(cargo_link) 7 | cmake_parse_arguments(CARGO_LINK "" "NAME" "TARGETS;EXCLUDE" ${ARGN}) 8 | 9 | file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cargo-link.c" "void cargo_link() {}") 10 | add_library(${CARGO_LINK_NAME} "${CMAKE_CURRENT_BINARY_DIR}/cargo-link.c") 11 | target_link_libraries(${CARGO_LINK_NAME} ${CARGO_LINK_TARGETS}) 12 | 13 | get_target_property(LINK_LIBRARIES ${CARGO_LINK_NAME} LINK_LIBRARIES) 14 | 15 | foreach(LINK_LIBRARY ${LINK_LIBRARIES}) 16 | get_target_property(_INTERFACE_LINK_LIBRARIES ${LINK_LIBRARY} INTERFACE_LINK_LIBRARIES) 17 | list(APPEND LINK_LIBRARIES ${_INTERFACE_LINK_LIBRARIES}) 18 | endforeach() 19 | list(REMOVE_DUPLICATES LINK_LIBRARIES) 20 | 21 | if(CARGO_LINK_EXCLUDE) 22 | list(REMOVE_ITEM LINK_LIBRARIES ${CARGO_LINK_EXCLUDE}) 23 | endif() 24 | 25 | set(LINK_DIRECTORIES "") 26 | foreach(LINK_LIBRARY ${LINK_LIBRARIES}) 27 | if(TARGET ${LINK_LIBRARY}) 28 | get_target_property(_IMPORTED_CONFIGURATIONS ${LINK_LIBRARY} IMPORTED_CONFIGURATIONS) 29 | list(FIND _IMPORTED_CONFIGURATIONS "RELEASE" _IMPORTED_CONFIGURATION_INDEX) 30 | if (NOT (${_IMPORTED_CONFIGURATION_INDEX} GREATER -1)) 31 | set(_IMPORTED_CONFIGURATION_INDEX 0) 32 | endif() 33 | list(GET _IMPORTED_CONFIGURATIONS ${_IMPORTED_CONFIGURATION_INDEX} _IMPORTED_CONFIGURATION) 34 | get_target_property(_IMPORTED_LOCATION ${LINK_LIBRARY} "IMPORTED_LOCATION_${_IMPORTED_CONFIGURATION}") 35 | get_filename_component(_IMPORTED_DIR ${_IMPORTED_LOCATION} DIRECTORY) 36 | get_filename_component(_IMPORTED_NAME ${_IMPORTED_LOCATION} NAME_WE) 37 | if(NOT WIN32) 38 | string(REGEX REPLACE "^lib" "" _IMPORTED_NAME ${_IMPORTED_NAME}) 39 | endif() 40 | list(APPEND LINK_DIRECTORIES ${_IMPORTED_DIR}) 41 | cargo_print("cargo:rustc-link-lib=static=${_IMPORTED_NAME}") 42 | else() 43 | if("${LINK_LIBRARY}" MATCHES "^.*/(.+)\\.framework$") 44 | set(FRAMEWORK_NAME ${CMAKE_MATCH_1}) 45 | cargo_print("cargo:rustc-link-lib=framework=${FRAMEWORK_NAME}") 46 | elseif("${LINK_LIBRARY}" MATCHES "^(.*)/(.+)\\.so$") 47 | set(LIBRARY_DIR ${CMAKE_MATCH_1}) 48 | set(LIBRARY_NAME ${CMAKE_MATCH_2}) 49 | if(NOT WIN32) 50 | string(REGEX REPLACE "^lib" "" LIBRARY_NAME ${LIBRARY_NAME}) 51 | endif() 52 | list(APPEND LINK_DIRECTORIES ${LIBRARY_DIR}) 53 | cargo_print("cargo:rustc-link-lib=${LIBRARY_NAME}") 54 | else() 55 | cargo_print("cargo:rustc-link-lib=${LINK_LIBRARY}") 56 | endif() 57 | endif() 58 | endforeach() 59 | list(REMOVE_DUPLICATES LINK_DIRECTORIES) 60 | 61 | foreach(LINK_DIRECTORY ${LINK_DIRECTORIES}) 62 | cargo_print("cargo:rustc-link-search=native=${LINK_DIRECTORY}") 63 | endforeach() 64 | endfunction() 65 | -------------------------------------------------------------------------------- /cmake/CMakeRustInformation.cmake: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Usage: rustc [OPTIONS] INPUT 4 | # 5 | # Options: 6 | # -h --help Display this message 7 | # --cfg SPEC Configure the compilation environment 8 | # -L [KIND=]PATH Add a directory to the library search path. The 9 | # optional KIND can be one of dependency, crate, native, 10 | # framework or all (the default). 11 | # -l [KIND=]NAME Link the generated crate(s) to the specified native 12 | # library NAME. The optional KIND can be one of static, 13 | # dylib, or framework. If omitted, dylib is assumed. 14 | # --crate-type [bin|lib|rlib|dylib|cdylib|staticlib|metadata] 15 | # Comma separated list of types of crates for the 16 | # compiler to emit 17 | # --crate-name NAME Specify the name of the crate being built 18 | # --emit [asm|llvm-bc|llvm-ir|obj|link|dep-info] 19 | # Comma separated list of types of output for the 20 | # compiler to emit 21 | # --print [crate-name|file-names|sysroot|cfg|target-list|target-cpus|target-features|relocation-models|code-models] 22 | # Comma separated list of compiler information to print 23 | # on stdout 24 | # -g Equivalent to -C debuginfo=2 25 | # -O Equivalent to -C opt-level=2 26 | # -o FILENAME Write output to 27 | # --out-dir DIR Write output to compiler-chosen filename in 28 | # --explain OPT Provide a detailed explanation of an error message 29 | # --test Build a test harness 30 | # --target TARGET Target triple for which the code is compiled 31 | # -W --warn OPT Set lint warnings 32 | # -A --allow OPT Set lint allowed 33 | # -D --deny OPT Set lint denied 34 | # -F --forbid OPT Set lint forbidden 35 | # --cap-lints LEVEL Set the most restrictive lint level. More restrictive 36 | # lints are capped at this level 37 | # -C --codegen OPT[=VALUE] 38 | # Set a codegen option 39 | # -V --version Print version info and exit 40 | # -v --verbose Use verbose output 41 | # 42 | # Additional help: 43 | # -C help Print codegen options 44 | # -W help Print 'lint' options and default settings 45 | # -Z help Print internal options for debugging rustc 46 | # --help -v Print the full set of options rustc accepts 47 | # 48 | 49 | # 50 | 51 | include(CMakeLanguageInformation) 52 | 53 | if(UNIX) 54 | set(CMAKE_Rust_OUTPUT_EXTENSION .o) 55 | else() 56 | set(CMAKE_Rust_OUTPUT_EXTENSION .obj) 57 | endif() 58 | 59 | set(CMAKE_Rust_ECHO_ALL "echo \"TARGET: TARGET_BASE: ") 60 | set(CMAKE_Rust_ECHO_ALL "${CMAKE_Rust_ECHO_ALL} OBJECT: OBJECTS: OBJECT_DIR: SOURCE: SOURCES: ") 61 | set(CMAKE_Rust_ECHO_ALL "${CMAKE_Rust_ECHO_ALL} LINK_LIBRARIES: FLAGS: LINK_FLAGS: \"") 62 | 63 | if(NOT CMAKE_Rust_CREATE_SHARED_LIBRARY) 64 | set(CMAKE_Rust_CREATE_SHARED_LIBRARY 65 | "echo \"CMAKE_Rust_CREATE_SHARED_LIBRARY\"" 66 | "${CMAKE_Rust_ECHO_ALL}" 67 | ) 68 | endif() 69 | 70 | if(NOT CMAKE_Rust_CREATE_SHARED_MODULE) 71 | set(CMAKE_Rust_CREATE_SHARED_MODULE 72 | "echo \"CMAKE_Rust_CREATE_SHARED_MODULE\"" 73 | "${CMAKE_Rust_ECHO_ALL}" 74 | ) 75 | endif() 76 | 77 | if(NOT CMAKE_Rust_CREATE_STATIC_LIBRARY) 78 | set(CMAKE_Rust_CREATE_STATIC_LIBRARY 79 | "echo \"CMAKE_Rust_CREATE_STATIC_LIBRARY\"" 80 | "${CMAKE_Rust_ECHO_ALL}" 81 | ) 82 | endif() 83 | 84 | if(NOT CMAKE_Rust_COMPILE_OBJECT) 85 | set(CMAKE_Rust_COMPILE_OBJECT 86 | "echo \"CMAKE_Rust_COMPILE_OBJECT\"" 87 | "${CMAKE_Rust_ECHO_ALL}" 88 | "${CMAKE_Rust_COMPILER} --emit obj -o ") 89 | endif() 90 | 91 | if(NOT CMAKE_Rust_LINK_EXECUTABLE) 92 | set(CMAKE_Rust_LINK_EXECUTABLE 93 | "echo \"CMAKE_Rust_LINK_EXECUTABLE\"" 94 | "${CMAKE_Rust_ECHO_ALL}" 95 | ) 96 | endif() 97 | 98 | mark_as_advanced( 99 | CMAKE_Rust_FLAGS 100 | CMAKE_Rust_FLAGS_DEBUG 101 | CMAKE_Rust_FLAGS_MINSIZEREL 102 | CMAKE_Rust_FLAGS_RELEASE 103 | CMAKE_Rust_FLAGS_RELWITHDEBINFO) 104 | 105 | set(CMAKE_Rust_INFORMATION_LOADED 1) 106 | 107 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------