3 # Marks the current folder as containing C++ modules, additionally enabling
4 # specific C++ language features as specified (all of these default to off):
7 # Links with the C++ runtime. Enable this for modules which use new/delete or
8 # RTTI, but do not require STL. This is the right choice if you see undefined
9 # references to operator new/delete, vector constructor/destructor iterator,
10 # type_info::vtable, ...
11 # Note: this only affects linking, so cannot be used for static libraries.
13 # Enables run-time type information. Enable this if the module uses typeid or
14 # dynamic_cast. You will probably need to enable WITH_RUNTIME as well, if
15 # you're not already using STL.
17 # Enables C++ exception handling. Enable this if the module uses try/catch or
18 # throw. You might also need this if you use a standard operator new (the one
21 # Enables standard C++ headers and links to the Standard Template Library.
22 # Use this for modules using anything from the std:: namespace, e.g. maps,
23 # strings, vectors, etc.
24 # Note: this affects both compiling (via include directories) and
25 # linking (by adding STL). Implies WITH_RUNTIME.
26 # FIXME: WITH_STL is currently also required for runtime headers such as
27 # <new> and <exception>. This is not a big issue because in stl-less
28 # environments you usually don't want those anyway; but we might want
29 # to have modules like this in the future.
33 # Enables the C++ language, but will cause errors if any runtime or standard
34 # library features are used. This should be the default for C++ in kernel
35 # mode or otherwise restricted environments.
36 # Note: this is required to get libgcc (for multiplication/division) linked
37 # in for C++ modules, and to set the correct language for precompiled
38 # header files, so it IS required even with no features specified.
39 # set_cpp(WITH_RUNTIME)
40 # Links with the C++ runtime, so that e.g. custom operator new implementations
41 # can be used in a restricted environment. This is also required for linking
42 # with libraries (such as ATL) which have RTTI enabled, even if the module in
43 # question does not use WITH_RTTI.
44 # set_cpp(WITH_RTTI WITH_EXCEPTIONS WITH_STL)
45 # The full package. This will adjust compiler and linker so that all C++
46 # features can be used.
48 cmake_parse_arguments(__cppopts "WITH_RUNTIME;WITH_RTTI;WITH_EXCEPTIONS;WITH_STL" "" "" ${ARGN})
49 if(__cppopts_UNPARSED_ARGUMENTS)
50 message(FATAL_ERROR "set_cpp: unparsed arguments ${__cppopts_UNPARSED_ARGUMENTS}")
53 if(__cppopts_WITH_RUNTIME)
56 if(__cppopts_WITH_RTTI)
58 replace_compile_flags("/GR-" "/GR")
60 replace_compile_flags_language("-fno-rtti" "-frtti" "CXX")
63 if(__cppopts_WITH_EXCEPTIONS)
65 replace_compile_flags("/EHs-c-" "/EHsc")
67 replace_compile_flags_language("-fno-exceptions" "-fexceptions" "CXX")
70 if(__cppopts_WITH_STL)
73 add_definitions(-DNATIVE_CPP_INCLUDE=${REACTOS_SOURCE_DIR}/include/c++)
74 include_directories(${REACTOS_SOURCE_DIR}/include/c++/stlport)
76 replace_compile_flags("-nostdinc" " ")
83 function(add_dependency_node _node)
84 if(GENERATE_DEPENDENCY_GRAPH)
85 get_target_property(_type ${_node} TYPE)
86 if(_type MATCHES SHARED_LIBRARY OR ${_node} MATCHES ntoskrnl)
87 file(APPEND ${REACTOS_BINARY_DIR}/dependencies.graphml " <node id=\"${_node}\"/>\n")
92 function(add_dependency_edge _source _target)
93 if(GENERATE_DEPENDENCY_GRAPH)
94 get_target_property(_type ${_source} TYPE)
95 if(_type MATCHES SHARED_LIBRARY)
96 file(APPEND ${REACTOS_BINARY_DIR}/dependencies.graphml " <edge source=\"${_source}\" target=\"${_target}\"/>\n")
101 function(add_dependency_header)
102 file(APPEND ${REACTOS_BINARY_DIR}/dependencies.graphml "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<graphml>\n <graph id=\"ReactOS dependencies\" edgedefault=\"directed\">\n")
105 function(add_dependency_footer)
106 add_dependency_node(ntdll)
107 file(APPEND ${REACTOS_BINARY_DIR}/dependencies.graphml " </graph>\n</graphml>\n")
110 function(add_message_headers _type)
111 if(${_type} STREQUAL UNICODE)
116 foreach(_in_FILE ${ARGN})
117 get_filename_component(FILE ${_in_FILE} NAME_WE)
118 macro_mc(${_flag} ${FILE})
120 OUTPUT ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.rc ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.h
121 COMMAND ${COMMAND_MC} ${MC_FLAGS}
122 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.mc)
123 set_source_files_properties(
124 ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.h ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.rc
125 PROPERTIES GENERATED TRUE)
126 add_custom_target(${FILE} ALL DEPENDS ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.h ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.rc)
131 cmake_parse_arguments(_LINK "MINIMIZE" "NAME;PATH;CMD_LINE_ARGS;ICON;GUID" "" ${ARGN})
132 if(NOT _LINK_NAME OR NOT _LINK_PATH)
133 message(FATAL_ERROR "You must provide name and path")
136 if(_LINK_CMD_LINE_ARGS)
137 set(_LINK_CMD_LINE_ARGS -c ${_LINK_CMD_LINE_ARGS})
141 set(_LINK_ICON -i ${_LINK_ICON})
145 set(_LINK_GUID -g ${_LINK_GUID})
149 set(_LINK_MINIMIZE "-m")
153 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_LINK_NAME}.lnk
154 COMMAND native-mkshelllink -o ${CMAKE_CURRENT_BINARY_DIR}/${_LINK_NAME}.lnk ${_LINK_CMD_LINE_ARGS} ${_LINK_ICON} ${_LINK_GUID} ${_LINK_MINIMIZE} ${_LINK_PATH}
155 DEPENDS native-mkshelllink)
156 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_LINK_NAME}.lnk PROPERTIES GENERATED TRUE)
159 macro(dir_to_num dir var)
160 if(${dir} STREQUAL reactos/system32)
162 elseif(${dir} STREQUAL reactos/system32/drivers)
164 elseif(${dir} STREQUAL reactos/Fonts)
166 elseif(${dir} STREQUAL reactos)
168 elseif(${dir} STREQUAL reactos/system32/drivers/etc)
170 elseif(${dir} STREQUAL reactos/inf)
172 elseif(${dir} STREQUAL reactos/bin)
174 elseif(${dir} STREQUAL reactos/bin/data)
176 elseif(${dir} STREQUAL reactos/media)
178 elseif(${dir} STREQUAL reactos/Microsoft.NET)
180 elseif(${dir} STREQUAL reactos/Microsoft.NET/Framework)
182 elseif(${dir} STREQUAL reactos/Microsoft.NET/Framework/v1.0.3705)
184 elseif(${dir} STREQUAL reactos/Microsoft.NET/Framework/v1.1.4322)
186 elseif(${dir} STREQUAL reactos/Microsoft.NET/Framework/v2.0.50727)
188 elseif(${dir} STREQUAL reactos/Resources)
190 elseif(${dir} STREQUAL reactos/Resources/Themes)
192 elseif(${dir} STREQUAL reactos/system32/wbem)
194 elseif(${dir} STREQUAL reactos/Resources/Themes/Lautus)
196 elseif(${dir} STREQUAL reactos/Help)
198 elseif(${dir} STREQUAL reactos/Config)
200 elseif(${dir} STREQUAL reactos/Cursors)
202 elseif(${dir} STREQUAL reactos/system32/ShellExt)
204 elseif(${dir} STREQUAL reactos/Temp)
206 elseif(${dir} STREQUAL reactos/system32/spool)
208 elseif(${dir} STREQUAL reactos/system32/spool/drivers)
210 elseif(${dir} STREQUAL reactos/system32/spool/drivers/color)
212 elseif(${dir} STREQUAL reactos/system32/spool/drivers/w32x86)
214 elseif(${dir} STREQUAL reactos/system32/spool/drivers/w32x86/3)
216 elseif(${dir} STREQUAL reactos/system32/spool/prtprocs)
218 elseif(${dir} STREQUAL reactos/system32/spool/prtprocs/w32x86)
220 elseif(${dir} STREQUAL reactos/system32/spool/PRINTERS)
222 elseif(${dir} STREQUAL reactos/system32/wbem/Repository)
224 elseif(${dir} STREQUAL reactos/system32/wbem/Repository/FS)
226 elseif(${dir} STREQUAL reactos/system32/wbem/mof/good)
228 elseif(${dir} STREQUAL reactos/system32/wbem/mof/bad)
230 elseif(${dir} STREQUAL reactos/system32/wbem/AdStatus)
232 elseif(${dir} STREQUAL reactos/system32/wbem/xml)
234 elseif(${dir} STREQUAL reactos/system32/wbem/Logs)
236 elseif(${dir} STREQUAL reactos/system32/wbem/AutoRecover)
238 elseif(${dir} STREQUAL reactos/system32/wbem/snmp)
240 elseif(${dir} STREQUAL reactos/system32/wbem/Performance)
242 elseif(${dir} STREQUAL reactos/twain_32)
244 elseif(${dir} STREQUAL reactos/repair)
246 elseif(${dir} STREQUAL reactos/Web)
248 elseif(${dir} STREQUAL reactos/Web/Wallpaper)
250 elseif(${dir} STREQUAL reactos/Prefetch)
252 elseif(${dir} STREQUAL reactos/security)
254 elseif(${dir} STREQUAL reactos/security/Database)
256 elseif(${dir} STREQUAL reactos/security/logs)
258 elseif(${dir} STREQUAL reactos/security/templates)
260 elseif(${dir} STREQUAL reactos/system32/CatRoot)
262 elseif(${dir} STREQUAL reactos/system32/CatRoot2)
265 message(FATAL_ERROR "Wrong destination: ${dir}")
269 function(add_cd_file)
270 cmake_parse_arguments(_CD "NO_CAB;NOT_IN_HYBRIDCD" "DESTINATION;NAME_ON_CD;TARGET" "FILE;FOR" ${ARGN})
271 if(NOT (_CD_TARGET OR _CD_FILE))
272 message(FATAL_ERROR "You must provide a target or a file to install!")
275 if(NOT _CD_DESTINATION)
276 message(FATAL_ERROR "You must provide a destination")
277 elseif(${_CD_DESTINATION} STREQUAL root)
278 set(_CD_DESTINATION "")
282 message(FATAL_ERROR "You must provide a cd name (or \"all\" for all of them) to install the file on!")
285 #get file if we need to
287 get_target_property(_CD_FILE ${_CD_TARGET} LOCATION_${CMAKE_BUILD_TYPE})
290 #do we add it to all CDs?
291 list(FIND _CD_FOR all __cd)
292 if(NOT __cd EQUAL -1)
293 list(REMOVE_AT _CD_FOR __cd)
294 list(INSERT _CD_FOR __cd "bootcd;livecd;regtest")
297 #do we add it to bootcd?
298 list(FIND _CD_FOR bootcd __cd)
299 if(NOT __cd EQUAL -1)
300 #whether or not we should put it in reactos.cab or directly on cd
303 foreach(item ${_CD_FILE})
305 #rename it in the cd tree
306 set(__file ${_CD_NAME_ON_CD})
308 get_filename_component(__file ${item} NAME)
310 set_property(GLOBAL APPEND PROPERTY BOOTCD_FILE_LIST "${_CD_DESTINATION}/${__file}=${item}")
311 #add it also into the hybridcd if not specified otherwise
312 if(NOT _CD_NOT_IN_HYBRIDCD)
313 set_property(GLOBAL APPEND PROPERTY HYBRIDCD_FILE_LIST "bootcd/${_CD_DESTINATION}/${__file}=${item}")
318 add_dependencies(bootcd ${_CD_TARGET} registry_inf)
321 #add it in reactos.cab
322 dir_to_num(${_CD_DESTINATION} _num)
323 file(RELATIVE_PATH __relative_file ${REACTOS_SOURCE_DIR} ${_CD_FILE})
324 file(APPEND ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.dff.dyn "\"${__relative_file}\" ${_num}\n")
325 unset(__relative_file)
327 #manage dependency - target level
328 add_dependencies(reactos_cab_inf ${_CD_TARGET})
330 # manage dependency - file level
331 set_property(GLOBAL APPEND PROPERTY REACTOS_CAB_DEPENDS ${_CD_FILE})
335 #do we add it to livecd?
336 list(FIND _CD_FOR livecd __cd)
337 if(NOT __cd EQUAL -1)
340 add_dependencies(livecd ${_CD_TARGET} registry_inf)
342 foreach(item ${_CD_FILE})
344 #rename it in the cd tree
345 set(__file ${_CD_NAME_ON_CD})
347 get_filename_component(__file ${item} NAME)
349 set_property(GLOBAL APPEND PROPERTY LIVECD_FILE_LIST "${_CD_DESTINATION}/${__file}=${item}")
350 #add it also into the hybridcd if not specified otherwise
351 if(NOT _CD_NOT_IN_HYBRIDCD)
352 set_property(GLOBAL APPEND PROPERTY HYBRIDCD_FILE_LIST "livecd/${_CD_DESTINATION}/${__file}=${item}")
357 #do we need also to add it to hybridcd?
358 list(FIND _CD_FOR hybridcd __cd)
359 if(NOT __cd EQUAL -1)
360 foreach(item ${_CD_FILE})
362 #rename it in the cd tree
363 set(__file ${_CD_NAME_ON_CD})
365 get_filename_component(__file ${item} NAME)
367 set_property(GLOBAL APPEND PROPERTY HYBRIDCD_FILE_LIST "${_CD_DESTINATION}/${__file}=${item}")
369 endif() #end hybridcd
371 #do we add it to regtest?
372 list(FIND _CD_FOR regtest __cd)
373 if(NOT __cd EQUAL -1)
374 #whether or not we should put it in reactos.cab or directly on cd
377 foreach(item ${_CD_FILE})
379 #rename it in the cd tree
380 set(__file ${_CD_NAME_ON_CD})
382 get_filename_component(__file ${item} NAME)
384 set_property(GLOBAL APPEND PROPERTY BOOTCDREGTEST_FILE_LIST "${_CD_DESTINATION}/${__file}=${item}")
388 add_dependencies(bootcdregtest ${_CD_TARGET} registry_inf)
391 #add it in reactos.cab
392 #dir_to_num(${_CD_DESTINATION} _num)
393 #file(APPEND ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.dff.dyn "${_CD_FILE} ${_num}\n")
396 # add_dependencies(reactos_cab ${_CD_TARGET})
402 function(create_iso_lists)
403 # generate reactos.cab before anything else
404 get_property(_filelist GLOBAL PROPERTY REACTOS_CAB_DEPENDS)
406 # begin with reactos.inf. We want this command to be always executed, so we pretend it generates another file although it will never do.
408 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf ${CMAKE_CURRENT_BINARY_DIR}/__some_non_existent_file
409 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.inf ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf
410 DEPENDS ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.inf reactos_cab_inf)
413 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/reactos.cab
414 COMMAND native-cabman -C ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.dff -RC ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf -N -P ${REACTOS_SOURCE_DIR}
415 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf native-cabman ${_filelist})
417 add_custom_target(reactos_cab DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/reactos.cab)
418 add_dependencies(reactos_cab reactos_cab_inf)
422 FILE ${CMAKE_CURRENT_BINARY_DIR}/reactos.cab
424 NO_CAB FOR bootcd regtest)
427 FILE ${CMAKE_CURRENT_BINARY_DIR}/livecd.iso
431 get_property(_filelist GLOBAL PROPERTY BOOTCD_FILE_LIST)
432 string(REPLACE ";" "\n" _filelist "${_filelist}")
433 file(APPEND ${REACTOS_BINARY_DIR}/boot/bootcd.lst "${_filelist}")
436 get_property(_filelist GLOBAL PROPERTY LIVECD_FILE_LIST)
437 string(REPLACE ";" "\n" _filelist "${_filelist}")
438 file(APPEND ${REACTOS_BINARY_DIR}/boot/livecd.lst "${_filelist}")
441 get_property(_filelist GLOBAL PROPERTY HYBRIDCD_FILE_LIST)
442 string(REPLACE ";" "\n" _filelist "${_filelist}")
443 file(APPEND ${REACTOS_BINARY_DIR}/boot/hybridcd.lst "${_filelist}")
446 get_property(_filelist GLOBAL PROPERTY BOOTCDREGTEST_FILE_LIST)
447 string(REPLACE ";" "\n" _filelist "${_filelist}")
448 file(APPEND ${REACTOS_BINARY_DIR}/boot/bootcdregtest.lst "${_filelist}")
452 # Create module_clean targets
453 function(add_clean_target _target)
454 set(_clean_working_directory ${CMAKE_CURRENT_BINARY_DIR})
455 if(CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "MinGW Makefiles")
456 set(_clean_command make clean)
457 elseif(CMAKE_GENERATOR STREQUAL "NMake Makefiles")
458 set(_clean_command nmake /nologo clean)
459 elseif(CMAKE_GENERATOR STREQUAL "Ninja")
460 set(_clean_command ninja -t clean ${_target})
461 set(_clean_working_directory ${REACTOS_BINARY_DIR})
463 add_custom_target(${_target}_clean
464 COMMAND ${_clean_command}
465 WORKING_DIRECTORY ${_clean_working_directory}
466 COMMENT "Cleaning ${_target}")
470 function(add_library name)
471 _add_library(${name} ${ARGN})
472 add_clean_target(${name})
475 function(add_executable name)
476 _add_executable(${name} ${ARGN})
477 add_clean_target(${name})
479 elseif(USE_FOLDER_STRUCTURE)
480 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
481 string(LENGTH ${CMAKE_SOURCE_DIR} CMAKE_SOURCE_DIR_LENGTH)
483 function(add_custom_target name)
484 _add_custom_target(${name} ${ARGN})
485 string(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR_LENGTH} -1 CMAKE_CURRENT_SOURCE_DIR_RELATIVE)
486 set_property(TARGET "${name}" PROPERTY FOLDER "${CMAKE_CURRENT_SOURCE_DIR_RELATIVE}")
489 function(add_library name)
490 _add_library(${name} ${ARGN})
491 get_target_property(_target_excluded ${name} EXCLUDE_FROM_ALL)
492 if(_target_excluded AND ${name} MATCHES "^lib.*")
493 set_property(TARGET "${name}" PROPERTY FOLDER "Importlibs")
495 string(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR_LENGTH} -1 CMAKE_CURRENT_SOURCE_DIR_RELATIVE)
496 set_property(TARGET "${name}" PROPERTY FOLDER "${CMAKE_CURRENT_SOURCE_DIR_RELATIVE}")
500 function(add_executable name)
501 _add_executable(${name} ${ARGN})
502 string(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR_LENGTH} -1 CMAKE_CURRENT_SOURCE_DIR_RELATIVE)
503 set_property(TARGET "${name}" PROPERTY FOLDER "${CMAKE_CURRENT_SOURCE_DIR_RELATIVE}")
507 if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
508 function(concatenate_files _output _file1)
509 file(TO_NATIVE_PATH "${_output}" _real_output)
510 file(TO_NATIVE_PATH "${_file1}" _file_list)
511 foreach(_file ${ARGN})
512 file(TO_NATIVE_PATH "${_file}" _real_file)
513 set(_file_list "${_file_list} + ${_real_file}")
517 COMMAND cmd.exe /C "copy /Y /B ${_file_list} ${_real_output} > nul"
518 DEPENDS ${_file1} ${ARGN})
521 macro(concatenate_files _output)
524 COMMAND cat ${ARGN} > ${_output}
529 function(add_importlibs _module)
530 add_dependency_node(${_module})
532 if("${LIB}" MATCHES "msvcrt")
533 add_target_compile_definitions(${_module} _DLL __USE_CRTIMP)
534 target_link_libraries(${_module} msvcrtex)
536 target_link_libraries(${_module} lib${LIB})
537 add_dependencies(${_module} lib${LIB})
538 add_dependency_edge(${_module} ${LIB})
542 function(set_module_type MODULE TYPE)
543 cmake_parse_arguments(__module "UNICODE;HOTPATCHABLE" "IMAGEBASE" "ENTRYPOINT" ${ARGN})
545 if(__module_UNPARSED_ARGUMENTS)
546 message(STATUS "set_module_type : unparsed arguments ${__module_UNPARSED_ARGUMENTS}, module : ${MODULE}")
549 # Add the module to the module group list, if it is defined
550 if(DEFINED CURRENT_MODULE_GROUP)
551 set_property(GLOBAL APPEND PROPERTY ${CURRENT_MODULE_GROUP}_MODULE_LIST "${MODULE}")
554 # Set subsystem. Also take this as an occasion
555 # to error out if someone gave a non existing type
556 if((${TYPE} STREQUAL nativecui) OR (${TYPE} STREQUAL nativedll)
557 OR (${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver) OR (${TYPE} STREQUAL kerneldll))
558 set(__subsystem native)
559 elseif(${TYPE} STREQUAL win32cui)
560 set(__subsystem console)
561 elseif(${TYPE} STREQUAL win32gui)
562 set(__subsystem windows)
563 elseif(NOT ((${TYPE} STREQUAL win32dll) OR (${TYPE} STREQUAL win32ocx)
564 OR (${TYPE} STREQUAL cpl) OR (${TYPE} STREQUAL module)))
565 message(FATAL_ERROR "Unknown type ${TYPE} for module ${MODULE}")
568 if(DEFINED __subsystem)
569 set_subsystem(${MODULE} ${__subsystem})
572 #set unicode definitions
574 add_target_compile_definitions(${MODULE} UNICODE _UNICODE)
577 # Handle hotpatchable images.
578 # GCC has this as a function attribute so we're handling it using DECLSPEC_HOTPATCH
579 if(__module_HOTPATCHABLE AND MSVC AND (NOT ARCH STREQUAL "arm"))
580 set_property(TARGET ${MODULE} APPEND_STRING PROPERTY COMPILE_FLAGS " /hotpatch")
581 if(ARCH STREQUAL "i386")
582 set_property(TARGET ${MODULE} APPEND_STRING PROPERTY LINK_FLAGS " /FUNCTIONPADMIN:5")
583 elseif(ARCH STREQUAL "amd64")
584 set_property(TARGET ${MODULE} APPEND_STRING PROPERTY LINK_FLAGS " /FUNCTIONPADMIN:6")
589 if(__module_ENTRYPOINT OR (__module_ENTRYPOINT STREQUAL "0"))
590 list(GET __module_ENTRYPOINT 0 __entrypoint)
591 list(LENGTH __module_ENTRYPOINT __length)
592 if(${__length} EQUAL 2)
593 list(GET __module_ENTRYPOINT 1 __entrystack)
594 elseif(NOT ${__length} EQUAL 1)
595 message(FATAL_ERROR "Wrong arguments for ENTRYPOINT parameter of set_module_type : ${__module_ENTRYPOINT}")
598 elseif(${TYPE} STREQUAL nativecui)
599 set(__entrypoint NtProcessStartup)
601 elseif(${TYPE} STREQUAL win32cui)
603 set(__entrypoint wmainCRTStartup)
605 set(__entrypoint mainCRTStartup)
607 elseif(${TYPE} STREQUAL win32gui)
609 set(__entrypoint wWinMainCRTStartup)
611 set(__entrypoint WinMainCRTStartup)
613 elseif((${TYPE} STREQUAL win32dll) OR (${TYPE} STREQUAL win32ocx)
614 OR (${TYPE} STREQUAL cpl))
615 set(__entrypoint DllMainCRTStartup)
617 elseif((${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver))
618 set(__entrypoint DriverEntry)
620 elseif(${TYPE} STREQUAL nativedll)
621 set(__entrypoint DllMain)
623 elseif(${TYPE} STREQUAL module)
627 if(DEFINED __entrypoint)
628 if(DEFINED __entrystack)
629 set_entrypoint(${MODULE} ${__entrypoint} ${__entrystack})
631 set_entrypoint(${MODULE} ${__entrypoint})
636 if(__module_IMAGEBASE)
637 set_image_base(${MODULE} ${__module_IMAGEBASE})
638 elseif(${TYPE} STREQUAL win32dll)
639 if(DEFINED baseaddress_${MODULE})
640 set_image_base(${MODULE} ${baseaddress_${MODULE}})
642 message(STATUS "${MODULE} has no base address")
644 elseif((${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver) OR (${TYPE} STREQUAL kerneldll))
645 set_image_base(${MODULE} 0x00010000)
648 # Now do some stuff which is specific to each type
649 if((${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver) OR (${TYPE} STREQUAL kerneldll))
650 add_dependencies(${MODULE} bugcodes)
651 if((${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver))
652 set_target_properties(${MODULE} PROPERTIES SUFFIX ".sys")
656 if(${TYPE} STREQUAL win32ocx)
657 set_target_properties(${MODULE} PROPERTIES SUFFIX ".ocx")
660 if(${TYPE} STREQUAL cpl)
661 set_target_properties(${MODULE} PROPERTIES SUFFIX ".cpl")
664 # do compiler specific stuff
665 set_module_type_toolchain(${MODULE} ${TYPE})
668 function(start_module_group __name)
669 if(DEFINED CURRENT_MODULE_GROUP)
670 message(FATAL_ERROR "CURRENT_MODULE_GROUP is already set ('${CURRENT_MODULE_GROUP}')")
672 set(CURRENT_MODULE_GROUP ${__name} PARENT_SCOPE)
675 function(end_module_group)
676 get_property(__modulelist GLOBAL PROPERTY ${CURRENT_MODULE_GROUP}_MODULE_LIST)
677 add_custom_target(${CURRENT_MODULE_GROUP})
678 foreach(__module ${__modulelist})
679 add_dependencies(${CURRENT_MODULE_GROUP} ${__module})
681 set(CURRENT_MODULE_GROUP PARENT_SCOPE)
684 function(preprocess_file __in __out)
686 foreach(__def ${ARGN})
687 list(APPEND __arg -D${__def})
690 add_custom_command(OUTPUT ${_out}
691 COMMAND ${CMAKE_C_COMPILER} /EP ${__arg}
694 add_custom_command(OUTPUT ${_out}
695 COMMAND ${CMAKE_C_COMPILER} -E ${__arg}
700 function(get_includes OUTPUT_VAR)
701 get_directory_property(_includes INCLUDE_DIRECTORIES)
702 foreach(arg ${_includes})
703 list(APPEND __tmp_var -I${arg})
705 set(${OUTPUT_VAR} ${__tmp_var} PARENT_SCOPE)
708 function(get_defines OUTPUT_VAR)
709 get_directory_property(_defines COMPILE_DEFINITIONS)
710 foreach(arg ${_defines})
711 list(APPEND __tmp_var -D${arg})
713 set(${OUTPUT_VAR} ${__tmp_var} PARENT_SCOPE)
717 function(add_object_library _target)
718 add_library(${_target} OBJECT ${ARGN})
721 function(add_object_library _target)
722 add_library(${_target} ${ARGN})
726 function(add_registry_inf)
727 # Add to the inf files list
728 foreach(_file ${ARGN})
729 set(_source_file "${CMAKE_CURRENT_SOURCE_DIR}/${_file}")
730 set_property(GLOBAL APPEND PROPERTY REGISTRY_INF_LIST ${_source_file})
734 function(create_registry_hives)
736 # Shortcut to the registry.inf file
737 set(_registry_inf "${CMAKE_BINARY_DIR}/boot/bootdata/registry.inf")
739 # Get the list of inf files
740 get_property(_inf_files GLOBAL PROPERTY REGISTRY_INF_LIST)
742 # Convert files to utf16le
743 foreach(_file ${_inf_files})
744 get_filename_component(_file_name ${_file} NAME_WE)
745 string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} _converted_file "${_file}")
746 string(REPLACE ${_file_name} "${_file_name}_utf16" _converted_file ${_converted_file})
747 add_custom_command(OUTPUT ${_converted_file}
748 COMMAND native-utf16le ${_file} ${_converted_file}
749 DEPENDS native-utf16le ${_file})
750 list(APPEND _converted_files ${_converted_file})
753 # Concatenate all registry files to registry.inf
754 concatenate_files(${_registry_inf} ${_converted_files})
756 # Add registry.inf to bootcd
757 add_custom_target(registry_inf DEPENDS ${_registry_inf})
758 add_cd_file(TARGET registry_inf
759 FILE ${_registry_inf}
765 list(APPEND _livecd_inf_files
767 ${CMAKE_SOURCE_DIR}/boot/bootdata/livecd.inf
768 ${CMAKE_SOURCE_DIR}/boot/bootdata/hiveinst.inf)
771 OUTPUT ${CMAKE_BINARY_DIR}/boot/bootdata/sam
772 ${CMAKE_BINARY_DIR}/boot/bootdata/default
773 ${CMAKE_BINARY_DIR}/boot/bootdata/security
774 ${CMAKE_BINARY_DIR}/boot/bootdata/software
775 ${CMAKE_BINARY_DIR}/boot/bootdata/system
776 COMMAND native-mkhive ${CMAKE_BINARY_DIR}/boot/bootdata/ ${_livecd_inf_files}
777 DEPENDS native-mkhive ${_livecd_inf_files})
779 add_custom_target(livecd_hives
780 DEPENDS ${CMAKE_BINARY_DIR}/boot/bootdata/sam
781 ${CMAKE_BINARY_DIR}/boot/bootdata/default
782 ${CMAKE_BINARY_DIR}/boot/bootdata/security
783 ${CMAKE_BINARY_DIR}/boot/bootdata/software
784 ${CMAKE_BINARY_DIR}/boot/bootdata/system)
787 FILE ${CMAKE_BINARY_DIR}/boot/bootdata/sam
788 ${CMAKE_BINARY_DIR}/boot/bootdata/default
789 ${CMAKE_BINARY_DIR}/boot/bootdata/security
790 ${CMAKE_BINARY_DIR}/boot/bootdata/software
791 ${CMAKE_BINARY_DIR}/boot/bootdata/system
793 DESTINATION reactos/system32/config
799 set(ROSSYM_LIB "rossym")