Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Prog2
/
labor_peldak
/
lab_02
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
47a81d43
authored
Apr 03, 2025
by
András Bodor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CMake projekt fájlok
parent
c275e866
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
182 additions
and
0 deletions
+182
-0
CMakeLists.txt
+35
-0
string1/CMakeLists.txt
+45
-0
string2_cpp/CMakeLists.txt
+102
-0
No files found.
CMakeLists.txt
0 → 100644
View file @
47a81d43
# Lab02 project
#
# Originally created: 2023-02-27.
#
# CMakeLists.txt --
# Elsődleges CMake file a lab_02 projekt fordításához.
# Fontos!
# Ez a fájl egy összesített script a két alprojekt kezeléséhez.
# Direkt egyesével is használhatóak, amennyiben a megfelelő
# almappát nyitjuk meg projektként.
# Ha ezt használjuk, akkor figyeljünk, mit próbálunk fordítani/futtatni!
# Például CLion-ban a futtatás gomb mellett megfelelő program van
# kiválasztva; VS-ben pedig megfelelő projektet probálunk elindítani.
# Használat:
# - parancssor: cmake -B _build -S . && cmake --build _build
# - CLion/Visual Studio: Megnyitni a mappát projektként
# - HSZK Visual Studio: HSZK-VS17 mappában előre legenerált projekt elérhető
cmake_minimum_required
(
VERSION 3.18
)
# Debian Bullseye
project
(
cpp_lab_02
HOMEPAGE_URL
"https://git.ik.bme.hu/Prog2/labor_peldak/lab_02"
VERSION 1.0.0
LANGUAGES C CXX
)
add_subdirectory
(
string1
)
add_subdirectory
(
string2_cpp
)
# A szóban megoldandó feladatok ellenőrzésére, ezeket
# nem érdemes fordítani, mert nem helyesek, ha valaki
# szeretné, az alábbi sorok kikommenzezésével lehet őket
# ismertetni CMake-el. Így meg lehet nézni, konkrétan
# mit ír ki a használt fordító a hibákra, esetleg
# önellenőrzésre
#add_executable(szoveges_feldat_const const_h.cpp)
#add_executable(szoveges_feldat_ref ref_h.cpp)
string1/CMakeLists.txt
0 → 100644
View file @
47a81d43
# Lab02 project
# string1 target
#
# Originally created: 2023-03-06.
#
# CMakeLists.txt --
# CMake file a lab_02 projekt string1 céljának fordításához.
# Használat:
# - parancssor: cmake -B _build -S . && cmake --build _build
# - CLion/Visual Studio: Megnyitni a mappát projektként
cmake_minimum_required
(
VERSION 3.18
)
# Debian Bullseye
project
(
cpp_lab_02_str1
HOMEPAGE_URL
"https://git.ik.bme.hu/Prog2/labor_peldak/lab_02"
VERSION 1.0.0
LANGUAGES C
)
add_library
(
memtrace_c STATIC
memtrace.c memtrace.h
)
target_compile_features
(
memtrace_c PRIVATE c_std_99
)
target_compile_definitions
(
memtrace_c PUBLIC MEMTRACE
_CRT_SECURE_NO_WARNINGS
)
add_executable
(
lab_02_string1
string1.c
string1.h
string1_main.c
gtest_lite.h
)
target_compile_features
(
lab_02_string1 PRIVATE c_std_99
)
set_target_properties
(
lab_02_string1 PROPERTIES
CXX_EXTENSIONS OFF
)
target_link_libraries
(
lab_02_string1 PRIVATE memtrace_c
)
# A C fordításra nincs teljes generate_warnings, csak az egyszerű konstans
# kapcsolókat használjuk.
target_compile_options
(
lab_02_string1 PRIVATE
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wall -Wextra -Werror>
$<$<CXX_COMPILER_ID:Clang>:-Wno-reserved-macro-identifier
-Wno-unused-macros -Wno-format
-Wno-strict-prototypes
-Wno-shorten-64-to-32
-Wno-unsafe-buffer-usage
-Wno-declaration-after-statement>
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX /wd4267>
)
string2_cpp/CMakeLists.txt
0 → 100644
View file @
47a81d43
# Lab02 project
# string2 target
#
# Originally created: 2023-02-27.
#
# CMakeLists.txt --
# CMake file a lab_02 projekt string2 céljának fordításához.
# Használat:
# - parancssor: cmake -B _build -S . && cmake --build _build
# - CLion/Visual Studio: Megnyitni a mappát projektként
# - Code::Blocks:
# 1) cmake -G "CodeBlocks - <1>" -B _build -S .
# - Windows: <1> = MinGW Makefiles
# - Unix: <2> = Unix Makefiles
# 2) A _build/*.cbp fájlt megnyitni
cmake_minimum_required
(
VERSION 3.18
)
# Debian Bullseye
include
(
CheckCXXCompilerFlag
)
project
(
cpp_lab_02_str2
HOMEPAGE_URL
"https://git.ik.bme.hu/Prog2/labor_peldak/lab_02"
VERSION 1.0.0
LANGUAGES CXX
)
add_library
(
memtrace_cxx STATIC
memtrace.cpp memtrace.h
)
target_compile_features
(
memtrace_cxx PRIVATE cxx_std_98
)
target_compile_definitions
(
memtrace_cxx PUBLIC MEMTRACE
)
add_executable
(
lab_02_string2
gtest_lite.h
string2.cpp
string2.h
string2_main.cpp
)
target_compile_features
(
lab_02_string2 PRIVATE cxx_std_98
)
set_target_properties
(
lab_02_string2 PROPERTIES
CXX_EXTENSIONS OFF
)
target_link_libraries
(
lab_02_string2 PRIVATE memtrace_cxx
)
target_compile_options
(
lab_02_string2 PRIVATE
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Werror>
$<$<CXX_COMPILER_ID:MSVC>:/WX>
)
## CheckWarningFlag(OptionName CacheName) --
# Ellenőrzi, hogy az használt fordító érti-e a kapott parancssori kapcsolót.
function
(
check_warning_flag OptionName CacheName
)
if
(
OptionName MATCHES
[[^/]]
)
set
(
WarningPrefix
""
)
else
()
set
(
WarningPrefix
"-W"
)
endif
()
check_cxx_compiler_flag
(
"
${
WarningPrefix
}${
OptionName
}
"
"HasWarning_
${
CacheName
}
"
)
set
(
"HAS_WARNING_
${
CacheName
}
"
${
HasWarning_
${
CacheName
}}
PARENT_SCOPE
)
endfunction
()
## generate_warnings(&Target) --
# Beállít hibakapcsolókat a kapott target-en.
function
(
generate_warnings _Target
)
set
(
gw_known_warnings
# GCC/Clang
extra pedantic error=vla error=non-virtual-dtor
parentheses logical-op reorder no-c++98-compat
no-reserved-macro-identifier no-unused-macros no-float-equal
no-zero-as-null-pointer-constant no-global-constructors
no-exit-time-destructors no-unsafe-buffer-usage
no-reserved-identifier
# _Is_...
no-old-style-cast
# gtest_lite
# MSVC
# conditional expression is constant (nem szereti az ELKESZULT) markot
/wd4127
# 'function': member function does not override any base class virtual member function
/we4263
# 'class': class has virtual functions, but destructor is not virtual
/we4265
# 'identifier': illegal qualified name in member declaration
/we4596
# 'symbol': exception specification does not match previous declaration
/we4986
4
/permissive-
/diagnostics:caret
)
# MSVC /Wall == clang -Weverything, arra nincs szükségünk
set
(
gw_found_warnings $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wall>
)
foreach
(
warn IN LISTS gw_known_warnings
)
string
(
MAKE_C_IDENTIFIER
"
${
warn
}
"
CacheName
)
check_warning_flag
(
"
${
warn
}
"
${
CacheName
}
)
if
(
HAS_WARNING_
${
CacheName
}
)
if
(
warn MATCHES
[[^/]]
)
set
(
WarningPrefix
""
)
else
()
set
(
WarningPrefix
"-W"
)
endif
()
list
(
APPEND gw_found_warnings
"
${
WarningPrefix
}${
warn
}
"
)
endif
()
endforeach
()
target_compile_options
(
"
${
_Target
}
"
PUBLIC
${
gw_found_warnings
}
)
endfunction
()
generate_warnings
(
lab_02_string2
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment