setup scaffold for cmake build
don't care for make and it makes importing other third party code harder
This commit is contained in:
parent
510d3547a2
commit
9a9d0043f2
2 changed files with 75 additions and 0 deletions
14
speech2/CMakeLists.txt
Normal file
14
speech2/CMakeLists.txt
Normal file
|
@ -0,0 +1,14 @@
|
|||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
project(testprog)
|
||||
|
||||
xp_init()
|
||||
|
||||
add_executable(testprog
|
||||
testprog.cpp
|
||||
)
|
||||
|
||||
# use the static multithreaded C library
|
||||
set_property(TARGET testprog PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
|
61
speech2/cmake/clangcl-winxp.cmake
Normal file
61
speech2/cmake/clangcl-winxp.cmake
Normal file
|
@ -0,0 +1,61 @@
|
|||
# Windows XP
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_VERSION 5.1)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86)
|
||||
|
||||
set(TARGET_VERSION_MAJOR 5)
|
||||
set(TARGET_VERSION_MINOR)
|
||||
|
||||
set(_MSVC_TRIPLET "i686-pc-windows-msvc")
|
||||
|
||||
# CXXRTDIR = $(VCDIR)/crt
|
||||
# UCRTDIR = $(VCDIR)/ucrt
|
||||
# PSDKDIR = $(VCDIR)/winsdk
|
||||
|
||||
if("$ENV{VCDIR}" STREQUAL "")
|
||||
message(FATAL_ERROR "Please set VCDIR in your environment to an appropiate path.")
|
||||
endif()
|
||||
|
||||
set(_CRTDIR "$ENV{VCDIR}/crt")
|
||||
set(_UCRTDIR "$ENV{VCDIR}/ucrt")
|
||||
set(_PSDKDIR "$ENV{VCDIR}/winsdk")
|
||||
|
||||
set(_CLANG_BASEFLAGS "-target ${_MSVC_TRIPLET} -fms-extensions -fms-compatibility-version=19 -isystem ${_CRTDIR}/include -isystem ${_UCRTDIR}/include -isystem ${_PSDKDIR}/include/shared -isystem ${_PSDKDIR}/include/um")
|
||||
set(_CLANG_ARCHFLAGS "-march=pentium4")
|
||||
|
||||
set(CMAKE_C_COMPILER "clang" CACHE FILEPATH "")
|
||||
set(CMAKE_CXX_COMPILER "clang++" CACHE FILEPATH "")
|
||||
set(CMAKE_LINKER "lld-link" CACHE FILEPATH "")
|
||||
|
||||
|
||||
set(CMAKE_C_FLAGS_INIT "${_CLANG_BASEFLAGS} ${_CLANG_ARCHFLAGS}")
|
||||
set(CMAKE_C_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_INIT} -fomit-frame-pointer")
|
||||
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_C_FLAGS_INIT}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT} ${CMAKE_CXX_FLAGS_INIT}")
|
||||
|
||||
# Set base linker library paths
|
||||
foreach(type EXE MODULE SHARED)
|
||||
set(CMAKE_${type}_LINKER_FLAGS "-Xlinker /libpath:${_CRTDIR}/lib/x86 -Xlinker /libpath:${_UCRTDIR}/lib -Xlinker /libpath:${_PSDKDIR}/lib")
|
||||
endforeach()
|
||||
|
||||
# Remove fluff libraries; projects should specify them
|
||||
set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
|
||||
|
||||
# Run this once after you call project() to replace broken
|
||||
macro(xp_init)
|
||||
foreach(lang C CXX)
|
||||
# have to patch the link commands to replace /MANIFEST:EMBED with /MANIFEST:NO
|
||||
# because ....
|
||||
set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
|
||||
"<CMAKE_${lang}_COMPILER> -nostartfiles -nostdlib <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /MANIFEST:EMBED -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:${CMAKE_SYSTEM_VERSION} <OBJECTS> <LINK_LIBRARIES> <MANIFESTS>" CACHE STRING "" FORCE)
|
||||
set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY} CACHE STRING "")
|
||||
set(CMAKE_${lang}_LINK_EXECUTABLE
|
||||
"<CMAKE_${lang}_COMPILER> -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /MANIFEST:NO -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:${CMAKE_SYSTEM_VERSION} ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES> <MANIFESTS>" CACHE STRING "" FORCE)
|
||||
|
||||
# also patch these so we can set the subsytem version
|
||||
set(CMAKE_${lang}_CREATE_WIN32_EXE "-Xlinker /subsystem:windows,${CMAKE_SYSTEM_VERSION}" CACHE STRING "")
|
||||
set(CMAKE_${lang}_CREATE_CONSOLE_EXE "-Xlinker /subsystem:console,${CMAKE_SYSTEM_VERSION}" CACHE STRING "")
|
||||
endforeach()
|
||||
endmacro()
|
Loading…
Reference in a new issue