Replies: 3 comments
-
Take a look at https://github.com/jart/cosmopolitan/blob/master/tool/scripts/cosmocc and https://github.com/jart/cosmopolitan/blob/master/tool/scripts/cosmoc++ which provide an alternative to the amalgamated release. |
Beta Was this translation helpful? Give feedback.
-
Thanks for sharing your work on the CMake toolchain for Cosmopolitan and SDL3! Regarding the issue with building shared libraries, you can explicitly disable it by setting the CMAKE_POSITION_INDEPENDENT_CODE variable to OFF. This will prevent CMake from generating build rules for building shared libraries. As for the issue with building SDL3 with the latest 2.2 release of Cosmopolitan, it's possible that some changes were made to the Cosmopolitan API that SDL3 relies on. You may need to update the SDL3 code to use the latest Cosmopolitan API. Alternatively, you can try building SDL3 with an older release of Cosmopolitan that is known to work. Regarding the built-in macros of the native toolchain seeping through, you can explicitly define COSMOPOLITAN and undefine other macros that are not relevant to the Cosmopolitan environment in your toolchain file. For example: Define COSMOPOLITAN and undefine other macros not relevant to Cosmopolitanadd_compile_definitions(COSMOPOLITAN) |
Beta Was this translation helpful? Give feedback.
-
I found this thread via Google when looking for how to use cosmocc with CMake. After much research and trial-and-error I was successfully able to compile my CMake project using cosmocc like this: https://jcbhmr.me/blog/cosmocc-cmake The trick for me was the CMAKE_USER_MAKE_RULES_OVERRIDE to set the .o file extension. cosmocc-override.cmake set(CMAKE_ASM_OUTPUT_EXTENSION .o)
set(CMAKE_C_OUTPUT_EXTENSION .o)
set(CMAKE_CXX_OUTPUT_EXTENSION .o) For some reason cosmocc doesn't seem to work if the object file extension is .obj 🤷♀️ it only works with .o |
Beta Was this translation helpful? Give feedback.
-
Hello!
I created a CMake toolchain file for Cosmopolitan at https://github.com/madebr/cosmopolitan-cmake-toolchain/.
It supports building C executables + static libraries targeting the cosmopolitan libc.
c++ and fortran are disabled because I could not find examples on how to get these working.
The CMake toolchain will happily attempt to build shared libraries, because I haven't disabled it explicitly (yet).
As a test, I added very basic support for building SDL3 at https://github.com/madebr/SDL/tree/cosmopolitan
It builds fine when using the latest unstable amalgamated cosmopolitan, but fails to build with the latest 2.2 release.
This work is just the initial work, because the test executables do not work and I have not been able yet to debug them with gdb.
Getting SDL3 to build was really straightforward, but it really annoying there is no non-amalgamated release available that provides the usual pthread headers (e.g.
stdio.h
,stdlib.h
, ...). SDL also attempts to include headers for intrinsics.Also, built-in macro's of the native toolchain seep through:
__linux__
is also defined in addition to__COSMOPOLITAN__
.Beta Was this translation helpful? Give feedback.
All reactions