From 2c11ab6c8dc228f24519f5b08952be76ce252e81 Mon Sep 17 00:00:00 2001 From: DolphyWind Date: Wed, 22 Feb 2023 11:43:31 +0300 Subject: [PATCH] Update CMakeLists.txt Get rid of the narrowing conversion warning Handle signals only if they are supported by OS --- CMakeLists.txt | 12 +++++++++--- src/Electra.cpp | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 63290cf..f70773d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,13 @@ set(CMAKE_CXX_STANDARD 20) project(ElectraLang VERSION 1.0.0) file(GLOB SOURCE_FILES "./src/*.cpp") -add_executable(electra ${SOURCE_FILES}) +if(WIN32) + add_executable(electra WIN32 ${SOURCE_FILES}) +else() + add_executable(electra ${SOURCE_FILES}) +endif() -target_include_directories(electra PRIVATE include) -install(TARGETS electra DESTINATION bin) +target_include_directories(electra PUBLIC include) +if(NOT WIN32) + install(TARGETS electra DESTINATION bin) +endif() diff --git a/src/Electra.cpp b/src/Electra.cpp index 0d33e64..5b7f920 100644 --- a/src/Electra.cpp +++ b/src/Electra.cpp @@ -79,11 +79,21 @@ Electra::Electra(int argc, char* argv[]) for(auto &p : m_generatorDataMap) m_generatorChars.push_back(p.first); + #ifdef SIGTERM signal(SIGTERM, &Electra::sigHandler); + #endif + #ifdef SIGINT signal(SIGINT, &Electra::sigHandler); - signal(SIGQUIT, &Electra::sigHandler); + #endif + #ifdef SIGQUIT + signal(SIGQUIT, &Electra::sigHandler); + #endif + #ifdef SIGKILL signal(SIGKILL, &Electra::sigHandler); + #endif + #ifdef SIGHUP signal(SIGHUP, &Electra::sigHandler); + #endif } Electra::~Electra() @@ -234,7 +244,7 @@ void Electra::createPortals() { if(!m_portalMap.contains(currentChar)) { - m_portalMap[currentChar] = {x, y}; + m_portalMap[currentChar] = {(int)x, (int)y}; } }