Skip to content

Instantly share code, notes, and snippets.

@drolevar
Created November 9, 2021 10:32
Show Gist options
  • Save drolevar/1a4432ce64510cbbd8ba5335636e5aa7 to your computer and use it in GitHub Desktop.
Save drolevar/1a4432ce64510cbbd8ba5335636e5aa7 to your computer and use it in GitHub Desktop.
WinCE 5.0 CMake toolchain for compiling with VS2005
# Set Windows CE version
set(CMAKE_VS_WINCE_VERSION "5.00")
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
# Make SDK_NAME variable a parameter to the toolchain
set(SDK_NAME "Undefined" CACHE STRING "Windows CE SDK name")
if(SDK_NAME STREQUAL "Undefined")
if (DEFINED ENV{SDK_NAME})
set(SDK_NAME "$ENV{SDK_NAME}")
else()
message(FATAL_ERROR "You must set SDK_NAME variable")
endif ()
else()
if (NOT DEFINED ENV{SDK_NAME})
set(ENV{SDK_NAME} "${SDK_NAME}")
endif ()
endif()
message(STATUS "Windows CE ${CMAKE_VS_WINCE_VERSION} SDK: ${SDK_NAME}")
# Get Visual Studio 2005 install location from registry
set(reg_vs8 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]")
get_filename_component(vsInstallDir ${reg_vs8} ABSOLUTE)
cmake_path(SET vsInstallDir NORMALIZE "${vsInstallDir}/../../FOO")
cmake_path(GET vsInstallDir PARENT_PATH vsInstallDir)
message(STATUS "Visual Studio 2005 install dir: ${vsInstallDir}")
# Emulate vcvars32.bat
cmake_path(NATIVE_PATH vsInstallDir NORMALIZE vsInstallDirNative)
set(ENV{VS_INSTALL_DIR} "${vsInstallDirNative}")
set(ENV{VC_INSTALL_DIR} "$ENV{VS_INSTALL_DIR}\\VC")
set(ENV{VisualStudioVersion} "8.0")
set(ENV{FrameworkDir} "$ENV{windir}\\Microsoft.NET\\Framework")
set(ENV{FrameworkVersion} "v2.0.50727")
set(ENV{FrameworkSDKDir} "${vsInstallDirNative}\\SDK\\v2.0")
set(ENV{DevEnvDir} "${vsInstallDirNative}\\Common7\\IDE")
set(ENV{PATH} "$ENV{DevEnvDir};$ENV{VC_INSTALL_DIR}\\BIN;${vsInstallDirNative}\\Common7\\Tools;${vsInstallDirNative}\\Common7\\Tools\\bin;$ENV{VC_INSTALL_DIR}\\PlatformSDK\\bin;$ENV{FrameworkSDKDir}\\bin;$ENV{FrameworkDir}\\$ENV{FrameworkVersion};$ENV{VC_INSTALL_DIR}\\VCPackages;$ENV{PATH}")
# Set include and link directories
set(VC_INSTALL_DIR "${vsInstallDir}/VC")
set(SDK_DIR "C:/Program Files (x86)/Windows CE Tools/wce500/${SDK_NAME}")
set(CEPROJ_INCLUDE_DIRECTORIES
"${VC_INSTALL_DIR}/ce/include"
"${SDK_DIR}/include/x86"
"${SDK_DIR}/include"
"${VC_INSTALL_DIR}/ce/atlmfc/include")
set(CEPROJ_LIBRARY_DIRECTORIES
"${SDK_DIR}/lib/x86"
"${VC_INSTALL_DIR}/ce/atlmfc/lib/x86"
"${VC_INSTALL_DIR}/ce/lib/x86")
include_directories(${CEPROJ_INCLUDE_DIRECTORIES})
link_directories(${CEPROJ_LIBRARY_DIRECTORIES})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment