Skip to content

Conversation

@kelson8
Copy link
Contributor

@kelson8 kelson8 commented Jan 28, 2026

This fixes an issue I was having when attempting to use this with FetchContent in CMake.
For some reason, it was set to use an SSH link for cloning the Unity tests instead of HTTPS, so I have changed the link.

With this change, you will no longer get a SSH error when trying to clone with the submodules.

Also, I fixed building this project on Linux by disabling this line in the CMakeLists.txt
target_link_options(tmj PRIVATE "LINKER:--version-script=src/tmj.sym")

I'm not exactly sure if that is needed or what this option does honestly.

@Zer0-One
Copy link
Owner

This can't be merged as-is. Changing the submodule to use https instead of ssh is fine, but that linker version script controls symbol visibility for the resulting shared object, so it's important. If it's failing to build, then you probably have a toolchain issue. What's your build setup?

@kelson8
Copy link
Contributor Author

kelson8 commented Jan 28, 2026

Well my CMake version is 4.2.2, using the Kitware apt repos for it, and I'm running Debian 13 on the build machine.
I'm trying to build this for Debug mode, and my gcc version is 14.2.0.
This is running over SSH connected to a local Linux machine with VSCode.

I checked and the tmj.sym file is in the src folder.

Here is my CMakeLists.txt that I am using for this, I have mostly just used the example from the readme for running this.

cmake_minimum_required(VERSION 3.22)

set(PROJECT_NAME "c-tiled-test")

# Get most source files
file(GLOB MAIN_SOURCES "src/*.c")

project(${PROJECT_NAME} C)

# Set the C standard
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)

include(FetchContent)

# Disable update cache for this, makes the project work offline
set(FETCHCONTENT_UPDATES_DISCONNECTED ON)

#-------------
# Libtmj
# Changed to use my fork, I had to modify the .gitmodules to make this part work.
#-------------

FetchContent_Declare(libtmj
#   GIT_REPOSITORY https://github.com/Zer0-One/libtmj.git
  GIT_REPOSITORY https://github.com/kelson8/libtmj.git
  GIT_TAG        e4f38d478a2f217f982701380485a3136d399e6f
)
FetchContent_MakeAvailable(libtmj)

#-------------
# Jansson for Json
#-------------

FetchContent_Declare(jansson
  GIT_REPOSITORY https://github.com/akheron/jansson.git
  GIT_TAG        v2.15.0
)
FetchContent_MakeAvailable(jansson)

add_executable(${PROJECT_NAME}
    ${MAIN_SOURCES}
    )

target_include_directories(${PROJECT_NAME} PRIVATE 
    src)

target_link_libraries(${PROJECT_NAME} PRIVATE
  tmj
  jansson
    )

And the errors from the linker when using this option

/usr/bin/ld: cannot open linker script file src/tmj.sym: No such file or directory
collect2: error: ld returned 1 exit status
gmake[2]: *** [_deps/libtmj-build/CMakeFiles/tmj.dir/build.make:167: _deps/libtmj-build/lib/libtmj.so.1.5.0] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:232: _deps/libtmj-build/CMakeFiles/tmj.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

@kelson8
Copy link
Contributor Author

kelson8 commented Jan 28, 2026

Actually, I changed that line to use this, and now it builds just fine, I added the ${CMAKE_CURRENT_SOURCE_DIR} variable to it.
Could this be because I am using Fetch Content for this?

if(NOT WIN32 AND NOT APPLE)
    target_link_options(tmj PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/tmj.sym")
endif()

@Zer0-One
Copy link
Owner

Squash your commits and I'll merge this.

@Zer0-One
Copy link
Owner

Gotta fix up the commit message body as well, you can just delete it and leave the summary line.

@Zer0-One Zer0-One merged commit f83e506 into Zer0-One:master Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants