debrouxl / tilibs

TILP (formerly GtkTiLink) can transfer data between Texas Instruments graphing calculators and a computer. It works with all link cables (parallel, serial, Black/Gray/Silver/Direct Link) and it supports the TI-Z80 series (73..86), the TI-eZ80 series (83PCE, 84+CE), the TI-68k series (89, 92, 92+, V200, 89T) and the Nspire series (Nspire Clickpad / Touchpad / CX, both CAS and non-CAS)
http://lpg.ticalc.org/prj_tilp
63 stars 23 forks source link

cmake: Compilation fails when trying to build libti* as a dependency #82

Closed the-blank-x closed 10 months ago

the-blank-x commented 10 months ago

Steps to Reproduce

  1. Save the following to main.cpp (the contents don't really matter):
    int main(void) {}
  2. Save the following to CMakeLists.txt:

    cmake_minimum_required(VERSION 3.25)
    
    project(test CXX)
    
    # /usr/bin/ld: CMakeFiles/ticonv_objlib.dir/src/charset.cc.o: relocation R_X86_64_PC32 against symbol `ti9x_charset' can not be used when making a shared object; recompile with -fPIC
    add_compile_options(-fPIC)
    
    add_subdirectory(thirdparty/tilibs)
    
    add_executable(${PROJECT_NAME} main.cpp)
    set_target_properties(${PROJECT_NAME}
       PROPERTIES
           CXX_STANDARD 20
           CXX_STANDARD_REQUIRED YES
           CXX_EXTENSIONS NO
    )
    target_link_libraries(${PROJECT_NAME} PRIVATE ticonv_static tifiles2_static ticalcs2_static ticables2_static)
  3. git clone https://github.com/debrouxl/tilibs.git thirdparty/tilibs
  4. mkdir build && cd build && cmake -B . ..
  5. make

Expected behavior

It builds successfully

Actual behavior

> make
[  1%] Generating de.gmo
[  2%] Generating fr.gmo
[  4%] Built target potfiles_3
[  5%] Building CXX object thirdparty/tilibs/libticonv/trunk/CMakeFiles/ticonv_objlib.dir/src/charset.cc.o
/tmp/test/thirdparty/tilibs/libticonv/trunk/src/charset.cc:490:9: warning: Warning: FINISH UTF-16-TO-TI-80 CONVERSION [-W#pragma-messages]
#pragma message("Warning: FINISH UTF-16-TO-TI-80 CONVERSION")
        ^
1 warning generated.
[  6%] Building CXX object thirdparty/tilibs/libticonv/trunk/CMakeFiles/ticonv_objlib.dir/src/filename.cc.o
[  7%] Building C object thirdparty/tilibs/libticonv/trunk/CMakeFiles/ticonv_objlib.dir/src/iconv.c.o
[  8%] Building CXX object thirdparty/tilibs/libticonv/trunk/CMakeFiles/ticonv_objlib.dir/src/ticonv.cc.o
[  8%] Building CXX object thirdparty/tilibs/libticonv/trunk/CMakeFiles/ticonv_objlib.dir/src/tokens.cc.o
[  9%] Building CXX object thirdparty/tilibs/libticonv/trunk/CMakeFiles/ticonv_objlib.dir/src/type2str.cc.o
[  9%] Built target ticonv_objlib
[ 10%] Generating de.gmo
[ 11%] Generating fr.gmo
[ 12%] Built target potfiles_1
[ 13%] Building CXX object thirdparty/tilibs/libtifiles/trunk/CMakeFiles/tifiles2_objlib.dir/src/cert.cc.o
In file included from /tmp/test/thirdparty/tilibs/libtifiles/trunk/src/cert.cc:23:
/tmp/test/thirdparty/tilibs/libtifiles/trunk/src/tifiles.h:29:10: fatal error: 'ticonv.h' file not found
#include <ticonv.h>
         ^~~~~~~~~~
1 error generated.
make[2]: *** [thirdparty/tilibs/libtifiles/trunk/CMakeFiles/tifiles2_objlib.dir/build.make:76: thirdparty/tilibs/libtifiles/trunk/CMakeFiles/tifiles2_objlib.dir/src/cert.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:488: thirdparty/tilibs/libtifiles/trunk/CMakeFiles/tifiles2_objlib.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
adriweb commented 10 months ago

Currently, tilp and gfm (see here: https://github.com/debrouxl/tilp_and_gfm maybe in the experimental branches, and my fork, more probably) are the only (?) projects using cmake and cmake-built tilibs. I don't believe I've seen your error before but then again tilp just uses the libs installed by cmake before so... it's not quite the same setup as what you're describing.