-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Copiază fișierele auxiliare în directorul de build * MSVC: compilare mai rapidă (?), codificare UTF-8, scoate telemetria (?) * Readme: cerințe de nivel înalt, instrucțiuni de compilare * Script pentru CMake * Update la versiuni mai noi pe macOS
- Loading branch information
Showing
10 changed files
with
231 additions
and
38 deletions.
There are no files selected for viewing
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
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
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,31 @@ | ||
# helper function to copy files to build directory and install directory without duplicating file names across commands | ||
function(copy_files) | ||
set(options OPTIONAL FAST) | ||
set(oneValueArgs) | ||
set(multiValueArgs FILES DIRECTORY) | ||
cmake_parse_arguments(PARSE_ARGV 0 ARG "${options}" "${oneValueArgs}" "${multiValueArgs}") | ||
|
||
# copy files to build dir | ||
foreach(file ${ARG_FILES}) | ||
add_custom_command( | ||
TARGET ${PROJECT_NAME} POST_BUILD | ||
COMMENT "Copying ${file}..." | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
${CMAKE_SOURCE_DIR}/${file} $<TARGET_FILE_DIR:${PROJECT_NAME}>) | ||
# ${CMAKE_CURRENT_BINARY_DIR}) | ||
endforeach() | ||
|
||
# copy folders to build dir | ||
foreach(dir ${ARG_DIRECTORY}) | ||
add_custom_command( | ||
TARGET ${PROJECT_NAME} POST_BUILD | ||
COMMENT "Copying directory ${dir}..." | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different | ||
${CMAKE_SOURCE_DIR}/${dir} $<TARGET_FILE_DIR:${PROJECT_NAME}>/${dir}) | ||
# ${CMAKE_CURRENT_BINARY_DIR}/${dir}) | ||
endforeach() | ||
|
||
# copy files and folders to install dir | ||
install(FILES ${ARG_FILES} DESTINATION ${DESTINATION_DIR}) | ||
install(DIRECTORY ${ARG_DIRECTORY} DESTINATION ${DESTINATION_DIR}) | ||
endfunction() |
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,126 @@ | ||
#!/usr/bin/bash | ||
|
||
DEFAULT_BUILD_DIR="build" | ||
DEFAULT_BUILD_TYPE="Debug" | ||
DEFAULT_INSTALL_DIR="install_dir" | ||
|
||
configure() { | ||
# cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug | ||
# | ||
BUILD_DIR="${DEFAULT_BUILD_DIR}" | ||
BUILD_TYPE="${DEFAULT_BUILD_TYPE}" | ||
INSTALL_DIR="${DEFAULT_INSTALL_DIR}" | ||
SOURCE_DIR="." | ||
CMAKE_OPTS=() | ||
|
||
while getopts ":b:c:g:i:s:t:" opt; do | ||
case "${opt}" in | ||
b) BUILD_DIR="${OPTARG}" | ||
;; | ||
c) IFS=" " read -r -a CMAKE_OPTS <<< "${OPTARG}" | ||
;; | ||
g) export CMAKE_GENERATOR="${OPTARG}" | ||
;; | ||
i) INSTALL_DIR="${OPTARG}" | ||
;; | ||
s) SOURCE_DIR="${OPTARG}" | ||
;; | ||
t) BUILD_TYPE="${OPTARG}" | ||
;; | ||
*) printf "Unknown option %s; available options: \n\ | ||
-b (build dir)\n\ | ||
-c (custom CMake options)\n\ | ||
-g (generator)\n\ | ||
-i (install dir prefix)\n\ | ||
-s (source dir)\n\ | ||
-t (build type)\n" "${opt}" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
cmake -S "${SOURCE_DIR}" \ | ||
-B "${BUILD_DIR}" \ | ||
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \ | ||
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ | ||
"${CMAKE_OPTS[@]}" | ||
} | ||
|
||
build() { | ||
# cmake --build build --config Debug -j6 | ||
# | ||
BUILD_DIR="${DEFAULT_BUILD_DIR}" | ||
BUILD_TYPE="${DEFAULT_BUILD_TYPE}" | ||
NPROC=6 | ||
|
||
while getopts ":b:h:j:t:" opt; do | ||
case "${opt}" in | ||
b) BUILD_DIR="${OPTARG}" | ||
;; | ||
j) NPROC="${OPTARG}" | ||
;; | ||
t) BUILD_TYPE="${OPTARG}" | ||
;; | ||
h) printf "Unknown option %s; available options: \n\ | ||
-b (build dir)\n\ | ||
-j (number of jobs for parallel build)\n\ | ||
-t (build type)\n" "${opt}" | ||
exit 1 | ||
;; | ||
*) | ||
;; | ||
esac | ||
shift $((OPTIND-1)) | ||
done | ||
|
||
cmake --build "${BUILD_DIR}" --config "${BUILD_TYPE}" -j "${NPROC}" "$@" | ||
} | ||
|
||
install() { | ||
# cmake --install build --config Debug --prefix install_dir | ||
# | ||
BUILD_DIR="${DEFAULT_BUILD_DIR}" | ||
BUILD_TYPE="${DEFAULT_BUILD_TYPE}" | ||
INSTALL_DIR="${DEFAULT_INSTALL_DIR}" | ||
while getopts ":b:i:t:" opt; do | ||
case "${opt}" in | ||
b) BUILD_DIR="${OPTARG}" | ||
;; | ||
i) INSTALL_DIR="${OPTARG}" | ||
;; | ||
t) BUILD_TYPE="${OPTARG}" | ||
;; | ||
*) printf "Unknown option %s; available options: \n\ | ||
-b (build dir)\n\ | ||
-i (install dir prefix)\n\ | ||
-t (build type)\n" "${opt}" | ||
exit 1 | ||
;; | ||
esac | ||
shift $((OPTIND-1)) | ||
done | ||
|
||
cmake --install "${BUILD_DIR}" --config "${BUILD_TYPE}" --prefix "${INSTALL_DIR}" | ||
} | ||
|
||
|
||
case "$1" in | ||
configure) | ||
shift | ||
configure "$@" | ||
;; | ||
build) | ||
shift | ||
build "$@" | ||
;; | ||
install) | ||
shift | ||
install "$@" | ||
;; | ||
*) printf "Unknown option %s; available options: \n\ | ||
configure\n\ | ||
build\n\ | ||
install\n" "${opt}" | ||
exit 1 | ||
esac | ||
|