JnCrMx / discord-game-sdk4j

Java bindings for Discord's Game SDK
MIT License
114 stars 23 forks source link

Missing toolchain files #57

Closed letorbi closed 1 year ago

letorbi commented 1 year ago

Hi JnCrMx,

when I try to compile the library, it fails with an number of CMake warnings and errors (see below). The most critical seems to be Could not find toolchain file: /home/letorbi/Desktop/discord-game-sdk4j/toolchains/linux-amd64.cmake.

I was able to fix this by creating my own toolchain file (see below), but the compilation then failed for the other platforms. Finally, after removing the compilation instructions for the other platform from /pom.xml, I was able to compile the library.

Could you please add your toolchain files to the project? I understand that they might be more or less specific to your system, but they would be a good reference for people like me, who try to compile the binaries on their own.

Cheers, Torben

File /toolchains/linux-amd64.cmake:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)

Log of the failed compilation:

[letorbi@kalliope master discord-game-sdk4j]$ mvn install -DskipTests
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------< com.github.jncrmx:discord-game-sdk4j >----------------
[INFO] Building discord-game-sdk4j 0.5.5
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ discord-game-sdk4j ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/letorbi/Desktop/discord-game-sdk4j/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ discord-game-sdk4j ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 41 source files to /home/letorbi/Desktop/discord-game-sdk4j/target/classes
[INFO] 
[INFO] --- maven-antrun-plugin:1.8:run (make-linux-amd64) @ discord-game-sdk4j ---
[INFO] Executing tasks

main:
    [mkdir] Created dir: /home/letorbi/Desktop/discord-game-sdk4j/target/native/linux/amd64
     [exec] CMake Warning (dev) in CMakeLists.txt:
     [exec]   No project() command is present.  The top-level CMakeLists.txt file must
     [exec]   contain a literal, direct call to the project() command.  Add a line of
     [exec]   code such as
     [exec] 
     [exec]     project(ProjectName)
     [exec] 
     [exec]   near the top of the file, but after cmake_minimum_required().
     [exec] 
     [exec]   CMake is pretending there is a "project(Project)" command on the first
     [exec]   line.
     [exec] This warning is for project developers.  Use -Wno-dev to suppress it.
     [exec] 
     [exec] -- Configuring incomplete, errors occurred!
     [exec] CMake Error at /usr/share/cmake/Modules/CMakeDetermineSystem.cmake:130 (message):
     [exec]   Could not find toolchain file:
     [exec]   /home/letorbi/Desktop/discord-game-sdk4j/toolchains/linux-amd64.cmake
     [exec] Call Stack (most recent call first):
     [exec]   CMakeLists.txt
     [exec] 
     [exec] 
     [exec] CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
     [exec] CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
     [exec] CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.866 s
[INFO] Finished at: 2022-12-13T23:54:11+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (make-linux-amd64) on project discord-game-sdk4j: An Ant BuildException has occured: exec returned: 1
[ERROR] around Ant part ...<exec failonerror="true" dir="/home/letorbi/Desktop/discord-game-sdk4j/target/native/linux/amd64" executable="cmake">... @ 5:120 in /home/letorbi/Desktop/discord-game-sdk4j/target/antrun/build-main.xml
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
JnCrMx commented 1 year ago

Okay, I added some example files now. I hope that clears things up :)

letorbi commented 1 year ago

Thanks for the fast fix. I'll take a look at your toolchains and try to compile for Mac. Hope it works somehow ;)

Interestingly I needed the linux-amd64.cmake toolchain even though I am on 64bit Linux. But I am new to CMake and Maven, so it just might be a glitch in my config.

Anyway, thanks again :)

JnCrMx commented 1 year ago

From what I can tell, the toolchain file needs to exist (so CMake can find it), but it can be empty. Ideally you would leave out the toolchain argument for CMake then, but that would mean deciding on one host system to compile with. That's why I decided to run every build with a toolchain and just use an empty one for the host system.

letorbi commented 1 year ago

Ah, ok. That makes sense. Never thought of using an empty toolchain file...

Thanks for the clarification.