#Compiler flags to use with the OpenWatcom compiler (wcl.exe) and NASM when #building FreeDOS. Pass the full path of this file to CMAKE_USER_MAKE_RULES_OVERRIDE #at some point in the FreeDOS CMakeLists.txt file prior to the project() #statement. See https://wiki.archlinux.org/index.php/Open_Watcom for details. #The Watcom toolchain file must declare the absolute path of the compiler, #assembler, linker and librarian. This "compiler rules" file declares rules #for how to invoke the tools to perform the three chores that CMake needs to #do: # - Compile a source file into an object file: CMAKE_C_COMPILE_OBJECT/CMAKE_ASM_NASM_COMPILE_OBJECT # - Link an executable from object files/libraries: CMAKE_C_LINK_EXECUTABLE # - Create a static library from a number of object files: CMAKE_C_CREATE_STATIC_LIBRARY #This file must declare all the above rules so that they refer to the tools #from the toolchain file invoked with the proper command line parameters. set (CMAKE_C_FLAGS_INIT "-bcl=dos") #Tells the "wcl" compiler to generate 16 bit DOS object code set (CMAKE_ASM_NASM_OBJECT_FORMAT obj) #The nasm assembler should generate 16 bit Microsoft object files #Do not add any linker options in order to create a "console" application (ie #the FreeDos file kernel.exe). By default, the CMake-distributed file #Modules\Platform\Windows-OpenWatcom.cmake #sets CMAKE_CREATE_CONSOLE_EXE to "system nt" which appears prior to the #expansion of of the CMAKE_C_LINK_EXECUTABLE rule below. Not what we #want - FreeDOS consists of 16 bit code only. See the CMake source file #cmMakefileExecutableTargetGenerator.cxx for details. set (CMAKE_CREATE_CONSOLE_EXE "") #Create an executable from object files and libraries using the Watcom wlink #tool. CMake has builtin support for the Watcom compiler, and will properly #identify and invoke that compiler. However, the builtin support assumes that #the compiler and the accompanying utilities (wlink/wlib) are in the PATH. We #remove that requirement by referring to instead of just #"wlink" in the rule below. CMAKE_LINKER expands to the absolute path of the #wlink launch script as declared in the toolchain file. set(CMAKE_C_LINK_EXECUTABLE " ${CMAKE_WLINK_QUIET} name file {} ") #Create a static library from a number of object files using the wlib tool. #The original rule for CMAKE_C_CREATE_STATIC_LIBRARY which is distributed with #cmake has hardcoded wlib as the librarian: #set(CMAKE_C_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -c -n -b ") #which assumes that "wlib" is in the PATH. The following new rule makes no #such assumption about the PATH, but instead relies on , which (in #the toolchain file) is initialized to the absolute path of the wlib program. set(CMAKE_C_CREATE_STATIC_LIBRARY " ${CMAKE_LIB_QUIET} -c -n -b ") #Create an object file from a C source file using the OpenWatcom compiler. #Note that we rely on , which has been initialized to the #absolute path of the C compiler launcher script by the toolchain file. set(CMAKE_C_COMPILE_OBJECT " ${CMAKE_WCL_QUIET} -d+ -fo -c -cc ") #Create an object file from an assembler source file by invoking NASM. The #standard CMake distribution does not apply below, so make sure # are applied. Make sure is not used, as it includes the C #compiler flags, which are not understood by the nasm assembler. Use #${CMAKE_ASM_NASM_FLAGS} instead. #See https://cmake.org/pipermail/cmake-developers/2016-March/028103.html set(CMAKE_ASM_NASM_COMPILE_OBJECT " ${CMAKE_ASM_NASM_FLAGS} -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o ")