-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #498 from sogartar/boian-cmake-2
Add Building with CMake
- Loading branch information
Showing
93 changed files
with
6,882 additions
and
23 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
.github/actions/install-cmake-build-dependencies/action.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
name: Install CMake build dependencies | ||
description: Install CMake build dependencies | ||
runs: | ||
using: composite | ||
steps: | ||
- uses: ./.github/actions/install-build-dependencies | ||
|
||
- name: Install CMake dependencies | ||
run: | | ||
if [ "$(uname)" = "Darwin" ]; then | ||
echo "CMake build for Darwin is unimplemented." | ||
exit 1 | ||
else | ||
# Compiler | ||
sudo apt-get install clang++-9 lld-9 tar bzip2 ninja-build | ||
sudo apt-get install tar bzip2 ninja-build | ||
# CMake | ||
wget https://github.com/Kitware/CMake/releases/download/v3.20.5/cmake-3.20.5-linux-x86_64.sh -O /tmp/cmake.sh | ||
sudo bash /tmp/cmake.sh --prefix=/usr/local --exclude-subdir --skip-license | ||
rm /tmp/cmake.sh | ||
# protobuf | ||
sudo apt-get install autoconf libtool make | ||
# Testing | ||
sudo apt-get install coreutils | ||
fi | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
cmake_minimum_required(VERSION 3.20) | ||
|
||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) | ||
message(FATAL_ERROR "In-source builds are unsupported. Please, build out of the source tree.") | ||
endif() | ||
|
||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
set(DARWIN TRUE) | ||
endif() | ||
|
||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
project(compiler_gym ASM C CXX) | ||
|
||
set(CMAKE_C_STANDARD 11 CACHE STRING "C standard to be used.") | ||
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to be used.") | ||
|
||
set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
|
||
list(APPEND CMAKE_MODULE_PATH | ||
${CMAKE_CURRENT_LIST_DIR}/build_tools/cmake/ | ||
) | ||
|
||
set(COMPILER_GYM_BUILD_TESTS OFF CACHE BOOL "Enable Compiler Gym tests.") | ||
|
||
include(cg_macros) | ||
include(cg_copts) | ||
include(cg_genrule) | ||
include(cg_cc_binary) | ||
include(cg_cc_library) | ||
include(cg_cc_test) | ||
include(cg_py_binary) | ||
include(cg_py_library) | ||
include(cg_py_test) | ||
include(cg_python) | ||
include(cg_add_all_subdirs) | ||
include(cg_filegroup) | ||
include(grpc) | ||
include(protobuf) | ||
|
||
set(COMPILER_GYM_PYTHONPATH "$ENV{PYTHONPATH}" CACHE STRING "PYTHONPATH environment variable during build step.") | ||
if (COMPILER_GYM_PYTHONPATH) | ||
string(PREPEND COMPILER_GYM_PYTHONPATH ":") | ||
endif() | ||
string(PREPEND COMPILER_GYM_PYTHONPATH "${CMAKE_BINARY_DIR}") | ||
include(set_command_pythonpath) | ||
|
||
set(DEFAULT_CMAKE_BUILD_TYPE "Release") | ||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
message(STATUS "No build type selected, default to ${DEFAULT_CMAKE_BUILD_TYPE}") | ||
set(CMAKE_BUILD_TYPE "${DEFAULT_CMAKE_BUILD_TYPE}" CACHE STRING "Build type (default ${DEFAULT_CMAKE_BUILD_TYPE})" FORCE) | ||
endif() | ||
|
||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) | ||
|
||
find_package(Python3 REQUIRED COMPONENTS Interpreter) | ||
|
||
include(external/external.cmake) | ||
add_subdirectory(compiler_gym) | ||
if(COMPILER_GYM_BUILD_TESTS) | ||
enable_testing() | ||
add_subdirectory(tests) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
#[=======================================================================[.rst: | ||
Result Variables | ||
^^^^^^^^^^^^^^^^ | ||
This will define the following variables in your project: | ||
``Bazel_FOUND`` | ||
true if Bazel is available. | ||
``Bazel_VERSION`` | ||
the version of Bazel. | ||
``Bazel_EXECUTABLE`` | ||
Path to the Bazel executable. | ||
#]=======================================================================] | ||
|
||
find_program(Bazel_EXECUTABLE bazel) | ||
|
||
execute_process(COMMAND "${Bazel_EXECUTABLE}" version | ||
RESULT_VARIABLE _BAZEL_VERSION_EXECUTE_PROCESS_RESULT_VARIABLE | ||
OUTPUT_VARIABLE _BAZEL_VERSION_EXECUTE_PROCESS_OUTPUT_VARIABLE | ||
ERROR_QUIET | ||
) | ||
|
||
set(Bazel_VERSION) | ||
|
||
if(_BAZEL_VERSION_EXECUTE_PROCESS_RESULT_VARIABLE EQUAL 0) | ||
string(REGEX MATCH "Build label: ([0-9a-zA-Z.]+)" | ||
_BAZEL_VERSION_REGEX_MATCH_OUTPUT_VARIABLE | ||
"${_BAZEL_VERSION_EXECUTE_PROCESS_OUTPUT_VARIABLE}" | ||
) | ||
|
||
if(CMAKE_MATCH_1) | ||
set(Bazel_VERSION "${CMAKE_MATCH_1}") | ||
endif() | ||
|
||
unset(_BAZEL_VERSION_REGEX_MATCH_OUTPUT_VARIABLE) | ||
endif() | ||
|
||
unset(_BAZEL_VERSION_EXECUTE_PROCESS_OUTPUT_VARIABLE) | ||
unset(_BAZEL_VERSION_EXECUTE_PROCESS_RESULT_VARIABLE) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
find_package_handle_standard_args(Bazel | ||
FOUND_VAR Bazel_FOUND | ||
REQUIRED_VARS Bazel_EXECUTABLE | ||
VERSION_VAR Bazel_VERSION | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
#[=======================================================================[.rst: | ||
Find Clog headers and libraries. | ||
Imported Targets | ||
^^^^^^^^^^^^^^^^ | ||
``Clog::libclog`` | ||
Result Variables | ||
^^^^^^^^^^^^^^^^ | ||
This will define the following variables in your project: | ||
``Clog_FOUND`` | ||
true if Clog is available. | ||
#]=======================================================================] | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
find_path(Clog_INCLUDE_DIRS clog.h | ||
PATH_SUFFIXES include) | ||
|
||
find_library(Clog_LIBRARIES clog PATH_SUFFIXES lib) | ||
if(Clog_INCLUDE_DIRS AND Clog_LIBRARIES) | ||
add_library(Clog::libclog UNKNOWN IMPORTED) | ||
set_target_properties(Clog::libclog PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "${Clog_INCLUDE_DIRS}" | ||
IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
IMPORTED_LOCATION "${Clog_LIBRARIES}") | ||
endif() | ||
find_package_handle_standard_args( | ||
Clog | ||
REQUIRED_VARS | ||
Clog_INCLUDE_DIRS | ||
Clog_LIBRARIES) |
Oops, something went wrong.