Giter Site home page Giter Site logo

Comments (12)

flagarde avatar flagarde commented on June 18, 2024 1

Other option would not be to make cpp-terminal-platforms STATIC ?

Marking cpp-terminal-platforms as STATIC can solve the problem.

❯ git diff
diff --git a/cpp-terminal/platforms/CMakeLists.txt b/cpp-terminal/platforms/CMakeLists.txt
index f886fee..f878d7c 100644
--- a/cpp-terminal/platforms/CMakeLists.txt
+++ b/cpp-terminal/platforms/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_library(cpp-terminal-platforms terminal.cpp tty.cpp terminfo.cpp input.cpp screen.cpp cursor.cpp)
+add_library(cpp-terminal-platforms STATIC terminal.cpp tty.cpp terminfo.cpp input.cpp screen.cpp cursor.cpp)
 target_link_libraries(cpp-terminal-platforms PRIVATE Warnings::Warnings)
 target_compile_options(cpp-terminal-platforms PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/utf-8 /wd4668 /wd4514>)
 target_include_directories(cpp-terminal-platforms PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}> $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}> $<INSTALL_INTERFACE:include>)

ruby in 🌐 fedora in cpp-terminal on  master [!] via △ v3.26.3 
❯ rm -rf build/ && cmake . -B build -DBUILD_SHARED_LIBS=ON  && cmake --build build/ -j6
-- The CXX compiler identification is GNU 13.0.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/ruby/build/cpp-terminal/build
[  6%] Building CXX object cpp-terminal/platforms/CMakeFiles/cpp-terminal-platforms.dir/terminal.cpp.o
[  6%] Building CXX object cpp-terminal/platforms/CMakeFiles/cpp-terminal-platforms.dir/tty.cpp.o
[  6%] Building CXX object cpp-terminal/platforms/CMakeFiles/cpp-terminal-platforms.dir/terminfo.cpp.o
[  8%] Building CXX object cpp-terminal/platforms/CMakeFiles/cpp-terminal-platforms.dir/screen.cpp.o
[ 10%] Building CXX object cpp-terminal/platforms/CMakeFiles/cpp-terminal-platforms.dir/input.cpp.o
[ 12%] Building CXX object cpp-terminal/platforms/CMakeFiles/cpp-terminal-platforms.dir/cursor.cpp.o
[ 14%] Linking CXX static library libcpp-terminal-platforms.a
[ 14%] Built target cpp-terminal-platforms
[ 20%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/prompt.cpp.o
[ 20%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/input.cpp.o
[ 24%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/color.cpp.o
[ 26%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/key.cpp.o
[ 20%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/window.cpp.o
[ 22%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/terminal.cpp.o
[ 30%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/event.cpp.o
[ 30%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/screen.cpp.o
[ 32%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/options.cpp.o
[ 34%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/cursor.cpp.o
[ 38%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/io.cpp.o
[ 38%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/style.cpp.o
[ 40%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/version.cpp.o
[ 42%] Linking CXX shared library libcpp-terminal.so
[ 42%] Built target cpp-terminal
[ 55%] Building CXX object examples/CMakeFiles/cin.dir/cin.cpp.o
[ 55%] Building CXX object examples/CMakeFiles/prompt_multiline.dir/prompt_multiline.cpp.o
[ 55%] Building CXX object tests/CMakeFiles/test_terminal.dir/test_terminal.cpp.o
[ 55%] Building CXX object examples/CMakeFiles/minimal.dir/minimal.cpp.o
[ 55%] Building CXX object examples/CMakeFiles/prompt_immediate.dir/prompt_immediate.cpp.o
[ 55%] Building CXX object tests/CMakeFiles/AttachConsole.dir/attach_console.test.cpp.o
[ 63%] Linking CXX executable AttachConsole
[ 63%] Linking CXX executable prompt_multiline
[ 63%] Linking CXX executable minimal
[ 63%] Linking CXX executable cin
[ 65%] Linking CXX executable prompt_immediate
[ 67%] Linking CXX executable test_terminal
[ 67%] Built target AttachConsole
[ 67%] Built target minimal
[ 67%] Built target prompt_immediate
[ 67%] Built target cin
[ 67%] Built target prompt_multiline
[ 71%] Building CXX object examples/CMakeFiles/prompt_simple.dir/prompt_simple.cpp.o
[ 73%] Building CXX object examples/CMakeFiles/kilo.dir/kilo.cpp.o
[ 73%] Building CXX object examples/CMakeFiles/prompt_not_immediate.dir/prompt_not_immediate.cpp.o
[ 75%] Building CXX object examples/CMakeFiles/menu_window.dir/menu_window.cpp.o
[ 77%] Building CXX object examples/CMakeFiles/menu.dir/menu.cpp.o
[ 85%] Linking CXX executable prompt_not_immediate
[ 85%] Linking CXX executable prompt_simple
[ 85%] Linking CXX executable kilo
[ 85%] Linking CXX executable menu
[ 85%] Built target test_terminal
[ 87%] Linking CXX executable menu_window
[ 89%] Building CXX object examples/CMakeFiles/keys.dir/keys.cpp.o
/home/ruby/build/cpp-terminal/examples/keys.cpp: In function ‘int main()’:
/home/ruby/build/cpp-terminal/examples/keys.cpp:66:15: warning: case value ‘525’ not in enumerated type ‘Term::Key::Value’ [-Wswitch]
   66 |               case Term::Key::ALT + Term::Key::ENTER: s = "Alt+ENTER"; break;
      |               ^~~~
[ 91%] Linking CXX executable keys
[ 91%] Built target prompt_simple
[ 91%] Built target prompt_not_immediate
[ 91%] Built target menu
[ 91%] Built target menu_window
[ 91%] Built target kilo
[ 95%] Building CXX object examples/CMakeFiles/colors.dir/colors.cpp.o
[ 95%] Building CXX object examples/CMakeFiles/read_stdin.dir/read_stdin.cpp.o
[100%] Linking CXX executable read_stdin
[100%] Linking CXX executable colors
[100%] Built target keys
[100%] Built target colors
[100%] Built target read_stdin

btw, I have a suggestion about the doctest library of the tests, maybe we can first use find_package(doctest) first, if not found, then use FetchContent to get it. I also do not konw the logic here, if cmake > 3.11, fetch doctest, else use find_package to find doctest?

if(CMAKE_VERSION GREATER_EQUAL 3.11)
include(FetchContent)
FetchContent_Declare(doctest GIT_REPOSITORY https://github.com/doctest/doctest.git GIT_TAG v2.4.9)
FetchContent_GetProperties(doctest)
if(NOT doctest_POPULATED)
set(DOCTEST_NO_INSTALL TRUE)
FetchContent_Populate(doctest)
add_subdirectory("${doctest_SOURCE_DIR}" "${doctest_BINARY_DIR}")
include("${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake")
unset(DOCTEST_NO_INSTALL)
endif()
else()
find_package(doctest QUIET)
if(NOT doctest_FOUND)
message(WARNING "CMake is too old to use FetchContent and doctest is not found !\nSkipping tests !")
return()
endif()
include(doctest)
endif()

I don't want yo rely on system install... So i fetch it with the version I want... Cmake before 3.11 have no fetcontent so i try to find the package (even if i don't like this)

from cpp-terminal.

flagarde avatar flagarde commented on June 18, 2024

@topazus Thx for the fix I will do a PR. Strange this it's not happening in my computer. Other option would not be to make cpp-terminal-platforms STATIC ? I would like to completly hide cpp-terminal-platforms to the user

from cpp-terminal.

topazus avatar topazus commented on June 18, 2024

@flagarde

#pragma once
#include "cpp-terminal/color.hpp"
#include "cpp-terminal/platforms/macros.hpp"
#include "cpp-terminal/style.hpp"

I am very well known with CMake. Maybe the public header file window.hpp of cpp-terminalincludes header filemacros.hppof cpp-terminal-platforms?
ref: https://cmake.org/pipermail/cmake/2019-December/070305.html

Continuing with the example I used above, if the public headers of the
middle library refer to anything from the inner library, then
target_link_libraries() should specify PUBLIC, regardless of whether middle
or inner are static or shared libraries.

from cpp-terminal.

flagarde avatar flagarde commented on June 18, 2024

It seems the problem is not an header problem but the linker problem... In the cin function that is inlined so the store_and_restore is not linked correctly.. what is strange is that kt is working on CI

from cpp-terminal.

flagarde avatar flagarde commented on June 18, 2024

@topazus could you provide your CC CXX environment variables? Or tell my the fedora ones

from cpp-terminal.

topazus avatar topazus commented on June 18, 2024

The default is gcc and g++.

from cpp-terminal.

topazus avatar topazus commented on June 18, 2024

The above build errors appeared when linking to libcpp-terminal-platforms.so, but the cpp-terminal links PRIVATE to cpp-terminal-platforms, which compiled target cpp-terminal-platforms is only visible to cpp-terminal, not available to the target that links cpp-terminal.

from cpp-terminal.

topazus avatar topazus commented on June 18, 2024

Other option would not be to make cpp-terminal-platforms STATIC ?

Marking cpp-terminal-platforms as STATIC can solve the problem.

build log
❯ git diff
diff --git a/cpp-terminal/platforms/CMakeLists.txt b/cpp-terminal/platforms/CMakeLists.txt
index f886fee..f878d7c 100644
--- a/cpp-terminal/platforms/CMakeLists.txt
+++ b/cpp-terminal/platforms/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_library(cpp-terminal-platforms terminal.cpp tty.cpp terminfo.cpp input.cpp screen.cpp cursor.cpp)
+add_library(cpp-terminal-platforms STATIC terminal.cpp tty.cpp terminfo.cpp input.cpp screen.cpp cursor.cpp)
 target_link_libraries(cpp-terminal-platforms PRIVATE Warnings::Warnings)
 target_compile_options(cpp-terminal-platforms PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/utf-8 /wd4668 /wd4514>)
 target_include_directories(cpp-terminal-platforms PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}> $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}> $<INSTALL_INTERFACE:include>)

ruby in 🌐 fedora in cpp-terminal on  master [!] via △ v3.26.3 
❯ rm -rf build/ && cmake . -B build -DBUILD_SHARED_LIBS=ON  && cmake --build build/ -j6
-- The CXX compiler identification is GNU 13.0.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/ruby/build/cpp-terminal/build
[  6%] Building CXX object cpp-terminal/platforms/CMakeFiles/cpp-terminal-platforms.dir/terminal.cpp.o
[  6%] Building CXX object cpp-terminal/platforms/CMakeFiles/cpp-terminal-platforms.dir/tty.cpp.o
[  6%] Building CXX object cpp-terminal/platforms/CMakeFiles/cpp-terminal-platforms.dir/terminfo.cpp.o
[  8%] Building CXX object cpp-terminal/platforms/CMakeFiles/cpp-terminal-platforms.dir/screen.cpp.o
[ 10%] Building CXX object cpp-terminal/platforms/CMakeFiles/cpp-terminal-platforms.dir/input.cpp.o
[ 12%] Building CXX object cpp-terminal/platforms/CMakeFiles/cpp-terminal-platforms.dir/cursor.cpp.o
[ 14%] Linking CXX static library libcpp-terminal-platforms.a
[ 14%] Built target cpp-terminal-platforms
[ 20%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/prompt.cpp.o
[ 20%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/input.cpp.o
[ 24%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/color.cpp.o
[ 26%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/key.cpp.o
[ 20%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/window.cpp.o
[ 22%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/terminal.cpp.o
[ 30%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/event.cpp.o
[ 30%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/screen.cpp.o
[ 32%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/options.cpp.o
[ 34%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/cursor.cpp.o
[ 38%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/io.cpp.o
[ 38%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/style.cpp.o
[ 40%] Building CXX object cpp-terminal/CMakeFiles/cpp-terminal.dir/version.cpp.o
[ 42%] Linking CXX shared library libcpp-terminal.so
[ 42%] Built target cpp-terminal
[ 55%] Building CXX object examples/CMakeFiles/cin.dir/cin.cpp.o
[ 55%] Building CXX object examples/CMakeFiles/prompt_multiline.dir/prompt_multiline.cpp.o
[ 55%] Building CXX object tests/CMakeFiles/test_terminal.dir/test_terminal.cpp.o
[ 55%] Building CXX object examples/CMakeFiles/minimal.dir/minimal.cpp.o
[ 55%] Building CXX object examples/CMakeFiles/prompt_immediate.dir/prompt_immediate.cpp.o
[ 55%] Building CXX object tests/CMakeFiles/AttachConsole.dir/attach_console.test.cpp.o
[ 63%] Linking CXX executable AttachConsole
[ 63%] Linking CXX executable prompt_multiline
[ 63%] Linking CXX executable minimal
[ 63%] Linking CXX executable cin
[ 65%] Linking CXX executable prompt_immediate
[ 67%] Linking CXX executable test_terminal
[ 67%] Built target AttachConsole
[ 67%] Built target minimal
[ 67%] Built target prompt_immediate
[ 67%] Built target cin
[ 67%] Built target prompt_multiline
[ 71%] Building CXX object examples/CMakeFiles/prompt_simple.dir/prompt_simple.cpp.o
[ 73%] Building CXX object examples/CMakeFiles/kilo.dir/kilo.cpp.o
[ 73%] Building CXX object examples/CMakeFiles/prompt_not_immediate.dir/prompt_not_immediate.cpp.o
[ 75%] Building CXX object examples/CMakeFiles/menu_window.dir/menu_window.cpp.o
[ 77%] Building CXX object examples/CMakeFiles/menu.dir/menu.cpp.o
[ 85%] Linking CXX executable prompt_not_immediate
[ 85%] Linking CXX executable prompt_simple
[ 85%] Linking CXX executable kilo
[ 85%] Linking CXX executable menu
[ 85%] Built target test_terminal
[ 87%] Linking CXX executable menu_window
[ 89%] Building CXX object examples/CMakeFiles/keys.dir/keys.cpp.o
/home/ruby/build/cpp-terminal/examples/keys.cpp: In function ‘int main()’:
/home/ruby/build/cpp-terminal/examples/keys.cpp:66:15: warning: case value ‘525’ not in enumerated type ‘Term::Key::Value’ [-Wswitch]
   66 |               case Term::Key::ALT + Term::Key::ENTER: s = "Alt+ENTER"; break;
      |               ^~~~
[ 91%] Linking CXX executable keys
[ 91%] Built target prompt_simple
[ 91%] Built target prompt_not_immediate
[ 91%] Built target menu
[ 91%] Built target menu_window
[ 91%] Built target kilo
[ 95%] Building CXX object examples/CMakeFiles/colors.dir/colors.cpp.o
[ 95%] Building CXX object examples/CMakeFiles/read_stdin.dir/read_stdin.cpp.o
[100%] Linking CXX executable read_stdin
[100%] Linking CXX executable colors
[100%] Built target keys
[100%] Built target colors
[100%] Built target read_stdin
btw, I have a suggestion about the doctest library of the tests, maybe we can first use `find_package(doctest)` first, if not found, then use FetchContent to get it. I also do not konw the logic here, if cmake > 3.11, fetch doctest, else use find_package to find doctest?

if(CMAKE_VERSION GREATER_EQUAL 3.11)
include(FetchContent)
FetchContent_Declare(doctest GIT_REPOSITORY https://github.com/doctest/doctest.git GIT_TAG v2.4.9)
FetchContent_GetProperties(doctest)
if(NOT doctest_POPULATED)
set(DOCTEST_NO_INSTALL TRUE)
FetchContent_Populate(doctest)
add_subdirectory("${doctest_SOURCE_DIR}" "${doctest_BINARY_DIR}")
include("${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake")
unset(DOCTEST_NO_INSTALL)
endif()
else()
find_package(doctest QUIET)
if(NOT doctest_FOUND)
message(WARNING "CMake is too old to use FetchContent and doctest is not found !\nSkipping tests !")
return()
endif()
include(doctest)
endif()

from cpp-terminal.

flagarde avatar flagarde commented on June 18, 2024

The above build errors appeared when linking to libcpp-terminal-platforms.so, but the cpp-terminal links PRIVATE to cpp-terminal-platforms, which compiled target cpp-terminal-platforms is only visible to cpp-terminal, not available to the target that links cpp-terminal.

This is indeed what I want to have.. I guess your linux add some other options to gcc by default because on the CI Ubuntu there is no compilation errors.

from cpp-terminal.

flagarde avatar flagarde commented on June 18, 2024

@topazus STATIC is done in other PR that is waiting to be merged

from cpp-terminal.

flagarde avatar flagarde commented on June 18, 2024

@topazus this is fixed now?

from cpp-terminal.

topazus avatar topazus commented on June 18, 2024

Thanks.

from cpp-terminal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.