project: create the windows toolchain
Some of the code is still linux only
This commit is contained in:
@@ -91,3 +91,25 @@ add_executable(${NAME} ${SRC_CXX_FILES})
|
|||||||
|
|
||||||
# Link raylib and raylib-cpp
|
# Link raylib and raylib-cpp
|
||||||
target_link_libraries(${NAME} PUBLIC raylib nlohmann_json::nlohmann_json)
|
target_link_libraries(${NAME} PUBLIC raylib nlohmann_json::nlohmann_json)
|
||||||
|
|
||||||
|
# Windows cross-compilation rule
|
||||||
|
|
||||||
|
if (NOT DEFINED CMAKE_CROSSCOMPILE_WINDOWS_HELPER_ADDED)
|
||||||
|
set(CMAKE_CROSSCOMPILE_WINDOWS_HELPER_ADDED TRUE)
|
||||||
|
|
||||||
|
set(WIN_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/toolchain-mingw-w64-x86_64.cmake" CACHE PATH "Toolchain for Win x86_64")
|
||||||
|
|
||||||
|
add_custom_target(cmake-win
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo "Configuring Windows x86_64 build in: ${CMAKE_SOURCE_DIR}/build-win-x86_64"
|
||||||
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
-S ${CMAKE_SOURCE_DIR}
|
||||||
|
-B ${CMAKE_SOURCE_DIR}/build-win-x86_64
|
||||||
|
-G "Ninja"
|
||||||
|
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=${WIN_TOOLCHAIN_FILE}
|
||||||
|
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_SOURCE_DIR}/build-win-x86_64 -- -v
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
COMMENT "Configure & build for Windows x86_64 (MinGW-w64)"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|||||||
21
toolchain-mingw-w64-x86_64.cmake
Normal file
21
toolchain-mingw-w64-x86_64.cmake
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
set(CMAKE_SYSTEM_NAME Windows)
|
||||||
|
set(CMAKE_SYSTEM_VERSION 1)
|
||||||
|
set(CMAKE_CROSSCOMPILING TRUE)
|
||||||
|
|
||||||
|
set(MINGW_TRIPLET "x86_64-w64-mingw32")
|
||||||
|
|
||||||
|
set(CMAKE_C_COMPILER ${MINGW_TRIPLET}-gcc)
|
||||||
|
set(CMAKE_CXX_COMPILER ${MINGW_TRIPLET}-g++)
|
||||||
|
set(CMAKE_RC_COMPILER ${MINGW_TRIPLET}-windres)
|
||||||
|
set(CMAKE_AR ${MINGW_TRIPLET}-ar)
|
||||||
|
set(CMAKE_RANLIB ${MINGW_TRIPLET}-ranlib)
|
||||||
|
set(CMAKE_OBJCOPY ${MINGW_TRIPLET}-objcopy)
|
||||||
|
|
||||||
|
set(CMAKE_FIND_ROOT_PATH /usr/${MINGW_TRIPLET})
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS_INIT "-static -static-libgcc -static-libstdc++")
|
||||||
|
set(CMAKE_CXX_FLAGS_INIT "-static -static-libgcc -static-libstdc++")
|
||||||
|
|
||||||
Reference in New Issue
Block a user