Commit 10de0ddb by András Bodor

cmake projekt

- CMakeLists.txt: A CMake projekt
- resistor.cpp: CMake-nek kell, hogy létezzen a fájl konfiguráláskor:
                ez egy üres fájl, hogy boldog legyen
parent e8d7bf96
# lab_04 project
#
# Originally created: 2023-03-20.
#
# CMakeLists.txt --
# CMake file a lab_04 projekt fordításához.
# Használat:
# - parancssor: cmake -B _build -S . && cmake --build _build
# - CLion/Visual Studio: Megnyitni a mappát projektként
# - HSZK Visual Studio: A meglévő .vcxproj fájlokat érdemes használni
cmake_minimum_required(VERSION 3.18) # Debian Bullseye
include(CheckCXXCompilerFlag)
project(cpp_lab_04
HOMEPAGE_URL "https://git.ik.bme.hu/Prog2/labor_peldak/lab_04"
VERSION 1.0.0
LANGUAGES CXX)
add_library(seged_target INTERFACE)
target_compile_features(seged_target INTERFACE cxx_std_11)
set_target_properties(seged_target PROPERTIES
INTERFACE_CXX_EXTENSIONS OFF)
# A következő parancs kikapcsolja GCC és Clang-en a másoló konstruktorok hívásának
# optimalizálását. Csak oktatási célból!
# Mivel MSVC-n nem lehetséges ezt megtenni, lehet más kimenetet generál.
target_compile_options(seged_target INTERFACE
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Werror>
$<$<CXX_COMPILER_ID:MSVC>:/WX>
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-fno-elide-constructors>)
add_executable(resistor_test
resistor.cpp
resistor.h
resistor_test.cpp)
add_executable(resistor_test2
resistor.cpp
resistor.h
resistor_test2.cpp)
add_executable(potmeter_test
resistor.cpp
resistor.h
console.h
console.cpp
potmeter.h
potmeter.cpp
potmeter_teszt.cpp)
target_link_libraries(resistor_test PRIVATE seged_target)
target_link_libraries(resistor_test2 PRIVATE seged_target)
target_link_libraries(potmeter_test PRIVATE seged_target)
## 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-format-nonliteral # Console::hMeter-ben txt-paraméter
no-unknown-argument # clang-cl nem érti az -fno-elide-constructors-t
no-c++98-compat-pedantic # variadic macro
no-reserved-identifier # _Is_...
no-old-style-cast # gtest_lite
no-shadow-field-in-constructor # gtest_lite
no-shorten-64-to-32 # 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(resistor_test)
generate_warnings(resistor_test2)
generate_warnings(potmeter_test)
/**
* \file resistor.cpp
* (UTF-8 kodolasu fajl. Allitsa at a megjenetes kodolasat,
* ha a tovabbi kommentek nem olvashatok helyesen!)
*
* Ohmikus ellenállást modellező osztály megvalósítása
*/
/**
* Itt kell megvalósítani a resistor.h-ban deklarált nem inline függvényeket.
* A Jportára ezt a fájlt kell feltölteni.
*/
#include "resistor.h"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment