Skip to content

Instantly share code, notes, and snippets.

@minlexx
Last active December 4, 2018 22:42
Show Gist options
  • Save minlexx/1a4b7ae3fe8e3574f62efc6c1018e976 to your computer and use it in GitHub Desktop.
Save minlexx/1a4b7ae3fe8e3574f62efc6c1018e976 to your computer and use it in GitHub Desktop.
hacky cmake script to build wine explorer.exe separately from whole wine (project to open in any C++ IDE)
cmake_minimum_required(VERSION 2.8)
project(wine_explorer)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_C_FLAGS
"-m32 -fPIC -Wall -fno-strict-aliasing -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Wshift-overflow=2 -Wstrict-prototypes -Wtype-limits -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wpointer-arith -Wlogical-op -gdwarf-2 -gstrict-dwarf -fno-omit-frame-pointer"
)
# Tweak this to your wine buld path
set(WINEDIR "/home/alexey/dev/wine")
set(WINEBUILDDIR "/home/alexey/dev/wine/build")
set(WINEGCC "${WINEBUILDDIR}/tools/winegcc/winegcc")
set(WINEWRC "${WINEBUILDDIR}/tools/wrc/wrc")
add_executable(${PROJECT_NAME}
"explorer.c"
"appbar.c"
"desktop.c"
"startmenu.c"
"systray.c"
"explorer.rc"
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
"__WINESRC__"
"_REENTRANT"
"_FORTIFY_SOURCE=0"
)
target_include_directories(${PROJECT_NAME} PRIVATE
"/usr/include/dbus-1.0"
"/usr/lib/i386-linux-gnu/dbus-1.0/include"
"${WINEDIR}/include"
"${WINEDIR}/programs/explorer"
"${WINEBUILDDIR}/include"
)
target_link_libraries(${PROJECT_NAME} PRIVATE
comctl32 shell32 oleaut32 ole32 shlwapi rpcrt4 user32 gdi32 advapi32
${WINEBUILDDIR}/libs/port/libwine_port.a
)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/explorer.res"
COMMAND "${WINEWRC}" -m32 --nostdinc -I. -I${WINEDIR}/include -I${WINEDIR}/programs/explorer -I${WINEBUILDDIR}/include -D__WINESRC__ ${CMAKE_CURRENT_SOURCE_DIR}/explorer.rc -o ${CMAKE_CURRENT_BINARY_DIR}/explorer.res
MAIN_DEPENDENCY "explorer.rc"
)
# Re-define a rule to link executables, because we need a custom wine linker to be used
set(CMAKE_C_LINK_EXECUTABLE "${WINEGCC} <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> explorer.res -o <TARGET> <LINK_LIBRARIES>")
message(STATUS ${CMAKE_C_LINK_EXECUTABLE})
set(CMAKE_C_LINK_FLAGS "-B${WINEBUILDDIR}/tools/winebuild -m32 -fasynchronous-unwind-tables -mwindows -municode")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment