From b438820edd7eeaf8f8eb506191f297ea44889565 Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Tue, 20 Jul 2021 22:36:50 +0200 Subject: [PATCH] BUILD: Fix compile and SEGV --- CMakeLists.txt | 3 +++ README.md | 2 +- src/VivyApplication.cc | 6 +++++- src/VivyApplication.hh | 2 +- vendor/lua-5.4.3/CMakeLists.txt | 7 +++++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 358bb9fd..d29954b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,9 @@ project(Vivy VERSION 0.1 LANGUAGES CXX) cmake_policy(SET CMP0100 NEW) # Let cmake use moc and uic for .hh files cmake_policy(SET CMP0009 NEW) # Do not follow symlinks with GLOB_RECURSE +# Pass -fPIC +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + # For Qt set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) diff --git a/README.md b/README.md index e4a74754..7f1ab8e1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Simply use cmake to build in another folder of the source folder: ``` -cmake -Bbuild -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_COMPILER=clang +cmake -Bbuild -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang ``` If you want to use the `compile_commands.json`, use the diff --git a/src/VivyApplication.cc b/src/VivyApplication.cc index 07e9c657..db735004 100644 --- a/src/VivyApplication.cc +++ b/src/VivyApplication.cc @@ -1,12 +1,13 @@ #include "VivyApplication.hh" #include "UI/MainWindow.hh" +#include <QtGlobal> #include <QIcon> #include <QFontDatabase> using namespace Vivy; -VivyApplication::VivyApplication(int argc, char **argv) +VivyApplication::VivyApplication(int &argc, char **argv) : QApplication(argc, argv) { } @@ -60,4 +61,7 @@ VivyApplication::getApplicationFont(Font id) const noexcept case Font::Default: return QFont(QFontDatabase::applicationFontFamilies(fontIdRegular).at(0)); } + + // Let the program crash + qFatal("UNREACHABLE"); } diff --git a/src/VivyApplication.hh b/src/VivyApplication.hh index 86c74041..cdae52b4 100644 --- a/src/VivyApplication.hh +++ b/src/VivyApplication.hh @@ -43,7 +43,7 @@ private: int fontIdBoldItalic; public: - VivyApplication(int argc, char **argv); + VivyApplication(int &argc, char **argv); ~VivyApplication() = default; int exec() noexcept; diff --git a/vendor/lua-5.4.3/CMakeLists.txt b/vendor/lua-5.4.3/CMakeLists.txt index 8e586510..e4cfda6f 100644 --- a/vendor/lua-5.4.3/CMakeLists.txt +++ b/vendor/lua-5.4.3/CMakeLists.txt @@ -5,6 +5,9 @@ if(WIN32) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() +# Pass -fPIC +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + file(GLOB Lua_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c") file(GLOB Lua_INC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h") list(REMOVE_ITEM Lua_SRC "src/lua.c" "src/luac.c") @@ -12,5 +15,9 @@ list(REMOVE_ITEM Lua_SRC "src/lua.c" "src/luac.c") add_library(lua STATIC ${Lua_SRC} ${Lua_INC}) target_include_directories(lua PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/") +if(UNIX) + target_link_libraries(lua m) +endif() + add_executable(lua-cli src/lua.c) target_link_libraries(lua-cli PRIVATE lua) -- GitLab