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)
81 function(add_dependency_node _node)
82 if(GENERATE_DEPENDENCY_GRAPH)
83 get_target_property(_type ${_node} TYPE)
84 if(_type MATCHES SHARED_LIBRARY OR ${_node} MATCHES ntoskrnl)
85 file(APPEND ${REACTOS_BINARY_DIR}/dependencies.graphml " <node id=\"${_node}\"/>\n")
90 function(add_dependency_edge _source _target)
91 if(GENERATE_DEPENDENCY_GRAPH)
92 get_target_property(_type ${_source} TYPE)
93 if(_type MATCHES SHARED_LIBRARY)
94 file(APPEND ${REACTOS_BINARY_DIR}/dependencies.graphml " <edge source=\"${_source}\" target=\"${_target}\"/>\n")
99 function(add_dependency_header)
100 file(APPEND ${REACTOS_BINARY_DIR}/dependencies.graphml "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<graphml>\n <graph id=\"ReactOS dependencies\" edgedefault=\"directed\">\n")
103 function(add_dependency_footer)
104 add_dependency_node(ntdll)
105 file(APPEND ${REACTOS_BINARY_DIR}/dependencies.graphml " </graph>\n</graphml>\n")
108 function(add_message_headers _type)
109 if(${_type} STREQUAL UNICODE)
114 foreach(_in_FILE ${ARGN})
115 get_filename_component(FILE ${_in_FILE} NAME_WE)
116 macro_mc(${_flag} ${FILE})
118 OUTPUT ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.rc ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.h
119 COMMAND ${COMMAND_MC} ${MC_FLAGS}
120 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.mc)
121 set_source_files_properties(
122 ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.h ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.rc
123 PROPERTIES GENERATED TRUE)
124 add_custom_target(${FILE} ALL DEPENDS ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.h ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.rc)
129 cmake_parse_arguments(_LINK "MINIMIZE" "NAME;PATH;CMD_LINE_ARGS;ICON;GUID" "" ${ARGN})
130 if(NOT _LINK_NAME OR NOT _LINK_PATH)
131 message(FATAL_ERROR "You must provide name and path")
134 if(_LINK_CMD_LINE_ARGS)
135 set(_LINK_CMD_LINE_ARGS -c ${_LINK_CMD_LINE_ARGS})
139 set(_LINK_ICON -i ${_LINK_ICON})
143 set(_LINK_GUID -g ${_LINK_GUID})
147 set(_LINK_MINIMIZE "-m")
151 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_LINK_NAME}.lnk
152 COMMAND native-mkshelllink -o ${CMAKE_CURRENT_BINARY_DIR}/${_LINK_NAME}.lnk ${_LINK_CMD_LINE_ARGS} ${_LINK_ICON} ${_LINK_GUID} ${_LINK_MINIMIZE} ${_LINK_PATH}
153 DEPENDS native-mkshelllink)
154 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_LINK_NAME}.lnk PROPERTIES GENERATED TRUE)
157 macro(dir_to_num dir var)
158 if(${dir} STREQUAL reactos/system32)
160 elseif(${dir} STREQUAL reactos/system32/drivers)
162 elseif(${dir} STREQUAL reactos/Fonts)
164 elseif(${dir} STREQUAL reactos)
166 elseif(${dir} STREQUAL reactos/system32/drivers/etc)
168 elseif(${dir} STREQUAL reactos/inf)
170 elseif(${dir} STREQUAL reactos/bin)
172 elseif(${dir} STREQUAL reactos/bin/data)
174 elseif(${dir} STREQUAL reactos/media)
176 elseif(${dir} STREQUAL reactos/Microsoft.NET)
178 elseif(${dir} STREQUAL reactos/Microsoft.NET/Framework)
180 elseif(${dir} STREQUAL reactos/Microsoft.NET/Framework/v1.0.3705)
182 elseif(${dir} STREQUAL reactos/Microsoft.NET/Framework/v1.1.4322)
184 elseif(${dir} STREQUAL reactos/Microsoft.NET/Framework/v2.0.50727)
186 elseif(${dir} STREQUAL reactos/Resources)
188 elseif(${dir} STREQUAL reactos/Resources/Themes)
190 elseif(${dir} STREQUAL reactos/system32/wbem)
192 elseif(${dir} STREQUAL reactos/Resources/Themes/Lautus)
194 elseif(${dir} STREQUAL reactos/Help)
196 elseif(${dir} STREQUAL reactos/Config)
198 elseif(${dir} STREQUAL reactos/Cursors)
200 elseif(${dir} STREQUAL reactos/system32/ShellExt)
202 elseif(${dir} STREQUAL reactos/Temp)
204 elseif(${dir} STREQUAL reactos/system32/spool)
206 elseif(${dir} STREQUAL reactos/system32/spool/drivers)
208 elseif(${dir} STREQUAL reactos/system32/spool/drivers/color)
210 elseif(${dir} STREQUAL reactos/system32/spool/drivers/w32x86)
212 elseif(${dir} STREQUAL reactos/system32/spool/drivers/w32x86/3)
214 elseif(${dir} STREQUAL reactos/system32/spool/prtprocs)
216 elseif(${dir} STREQUAL reactos/system32/spool/prtprocs/w32x86)
218 elseif(${dir} STREQUAL reactos/system32/spool/PRINTERS)
220 elseif(${dir} STREQUAL reactos/system32/wbem/Repository)
222 elseif(${dir} STREQUAL reactos/system32/wbem/Repository/FS)
224 elseif(${dir} STREQUAL reactos/system32/wbem/mof/good)
226 elseif(${dir} STREQUAL reactos/system32/wbem/mof/bad)
228 elseif(${dir} STREQUAL reactos/system32/wbem/AdStatus)
230 elseif(${dir} STREQUAL reactos/system32/wbem/xml)
232 elseif(${dir} STREQUAL reactos/system32/wbem/Logs)
234 elseif(${dir} STREQUAL reactos/system32/wbem/AutoRecover)
236 elseif(${dir} STREQUAL reactos/system32/wbem/snmp)
238 elseif(${dir} STREQUAL reactos/system32/wbem/Performance)
240 elseif(${dir} STREQUAL reactos/twain_32)
242 elseif(${dir} STREQUAL reactos/repair)
244 elseif(${dir} STREQUAL reactos/Web)
246 elseif(${dir} STREQUAL reactos/Web/Wallpaper)
248 elseif(${dir} STREQUAL reactos/Prefetch)
250 elseif(${dir} STREQUAL reactos/security)
252 elseif(${dir} STREQUAL reactos/security/Database)
254 elseif(${dir} STREQUAL reactos/security/logs)
256 elseif(${dir} STREQUAL reactos/security/templates)
258 elseif(${dir} STREQUAL reactos/system32/CatRoot)
260 elseif(${dir} STREQUAL reactos/system32/CatRoot2)
263 message(FATAL_ERROR "Wrong destination: ${dir}")
267 function(add_cd_file)
268 cmake_parse_arguments(_CD "NO_CAB;NOT_IN_HYBRIDCD" "DESTINATION;NAME_ON_CD;TARGET" "FILE;FOR" ${ARGN})
269 if(NOT (_CD_TARGET OR _CD_FILE))
270 message(FATAL_ERROR "You must provide a target or a file to install!")
273 if(NOT _CD_DESTINATION)
274 message(FATAL_ERROR "You must provide a destination")
275 elseif(${_CD_DESTINATION} STREQUAL root)
276 set(_CD_DESTINATION "")
280 message(FATAL_ERROR "You must provide a cd name (or \"all\" for all of them) to install the file on!")
283 #get file if we need to
285 get_target_property(_CD_FILE ${_CD_TARGET} LOCATION_${CMAKE_BUILD_TYPE})
288 #do we add it to all CDs?
289 list(FIND _CD_FOR all __cd)
290 if(NOT __cd EQUAL -1)
291 list(REMOVE_AT _CD_FOR __cd)
292 list(INSERT _CD_FOR __cd "bootcd;livecd;regtest")
295 #do we add it to bootcd?
296 list(FIND _CD_FOR bootcd __cd)
297 if(NOT __cd EQUAL -1)
298 #whether or not we should put it in reactos.cab or directly on cd
301 foreach(item ${_CD_FILE})
303 #rename it in the cd tree
304 set(__file ${_CD_NAME_ON_CD})
306 get_filename_component(__file ${item} NAME)
308 set_property(GLOBAL APPEND PROPERTY BOOTCD_FILE_LIST "${_CD_DESTINATION}/${__file}=${item}")
309 #add it also into the hybridcd if not specified otherwise
310 if(NOT _CD_NOT_IN_HYBRIDCD)
311 set_property(GLOBAL APPEND PROPERTY HYBRIDCD_FILE_LIST "bootcd/${_CD_DESTINATION}/${__file}=${item}")
316 add_dependencies(bootcd ${_CD_TARGET} converted_hives)
319 #add it in reactos.cab
320 dir_to_num(${_CD_DESTINATION} _num)
321 file(RELATIVE_PATH __relative_file ${REACTOS_SOURCE_DIR} ${_CD_FILE})
322 file(APPEND ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.dff.dyn "\"${__relative_file}\" ${_num}\n")
323 unset(__relative_file)
325 #manage dependency - target level
326 add_dependencies(reactos_cab_inf ${_CD_TARGET})
328 # manage dependency - file level
329 set_property(GLOBAL APPEND PROPERTY REACTOS_CAB_DEPENDS ${_CD_FILE})
333 #do we add it to livecd?
334 list(FIND _CD_FOR livecd __cd)
335 if(NOT __cd EQUAL -1)
338 add_dependencies(livecd ${_CD_TARGET} converted_hives)
340 foreach(item ${_CD_FILE})
342 #rename it in the cd tree
343 set(__file ${_CD_NAME_ON_CD})
345 get_filename_component(__file ${item} NAME)
347 set_property(GLOBAL APPEND PROPERTY LIVECD_FILE_LIST "${_CD_DESTINATION}/${__file}=${item}")
348 #add it also into the hybridcd if not specified otherwise
349 if(NOT _CD_NOT_IN_HYBRIDCD)
350 set_property(GLOBAL APPEND PROPERTY HYBRIDCD_FILE_LIST "livecd/${_CD_DESTINATION}/${__file}=${item}")
355 #do we need also to add it to hybridcd?
356 list(FIND _CD_FOR hybridcd __cd)
357 if(NOT __cd EQUAL -1)
358 foreach(item ${_CD_FILE})
360 #rename it in the cd tree
361 set(__file ${_CD_NAME_ON_CD})
363 get_filename_component(__file ${item} NAME)
365 set_property(GLOBAL APPEND PROPERTY HYBRIDCD_FILE_LIST "${_CD_DESTINATION}/${__file}=${item}")
367 endif() #end hybridcd
369 #do we add it to regtest?
370 list(FIND _CD_FOR regtest __cd)
371 if(NOT __cd EQUAL -1)
372 #whether or not we should put it in reactos.cab or directly on cd
375 foreach(item ${_CD_FILE})
377 #rename it in the cd tree
378 set(__file ${_CD_NAME_ON_CD})
380 get_filename_component(__file ${item} NAME)
382 set_property(GLOBAL APPEND PROPERTY BOOTCDREGTEST_FILE_LIST "${_CD_DESTINATION}/${__file}=${item}")
386 add_dependencies(bootcdregtest ${_CD_TARGET} converted_hives)
389 #add it in reactos.cab
390 #dir_to_num(${_CD_DESTINATION} _num)
391 #file(APPEND ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.dff.dyn "${_CD_FILE} ${_num}\n")
394 # add_dependencies(reactos_cab ${_CD_TARGET})
400 function(create_iso_lists)
401 # generate reactos.cab before anything else
402 get_property(_filelist GLOBAL PROPERTY REACTOS_CAB_DEPENDS)
404 # begin with reactos.inf. We want this command to be always executed, so we pretend it generates another file although it will never do.
406 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf ${CMAKE_CURRENT_BINARY_DIR}/__some_non_existent_file
407 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.inf ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf
408 DEPENDS ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.inf reactos_cab_inf)
411 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/reactos.cab
412 COMMAND native-cabman -C ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.dff -RC ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf -N -P ${REACTOS_SOURCE_DIR}
413 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf native-cabman ${_filelist})
415 add_custom_target(reactos_cab DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/reactos.cab)
416 add_dependencies(reactos_cab reactos_cab_inf)
420 FILE ${CMAKE_CURRENT_BINARY_DIR}/reactos.cab
422 NO_CAB FOR bootcd regtest)
425 FILE ${CMAKE_CURRENT_BINARY_DIR}/livecd.iso
429 get_property(_filelist GLOBAL PROPERTY BOOTCD_FILE_LIST)
430 string(REPLACE ";" "\n" _filelist "${_filelist}")
431 file(APPEND ${REACTOS_BINARY_DIR}/boot/bootcd.lst "${_filelist}")
434 get_property(_filelist GLOBAL PROPERTY LIVECD_FILE_LIST)
435 string(REPLACE ";" "\n" _filelist "${_filelist}")
436 file(APPEND ${REACTOS_BINARY_DIR}/boot/livecd.lst "${_filelist}")
439 get_property(_filelist GLOBAL PROPERTY HYBRIDCD_FILE_LIST)
440 string(REPLACE ";" "\n" _filelist "${_filelist}")
441 file(APPEND ${REACTOS_BINARY_DIR}/boot/hybridcd.lst "${_filelist}")
444 get_property(_filelist GLOBAL PROPERTY BOOTCDREGTEST_FILE_LIST)
445 string(REPLACE ";" "\n" _filelist "${_filelist}")
446 file(APPEND ${REACTOS_BINARY_DIR}/boot/bootcdregtest.lst "${_filelist}")
450 # Create module_clean targets
451 function(add_clean_target _target)
452 set(_clean_working_directory ${CMAKE_CURRENT_BINARY_DIR})
453 if(CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "MinGW Makefiles")
454 set(_clean_command make clean)
455 elseif(CMAKE_GENERATOR STREQUAL "NMake Makefiles")
456 set(_clean_command nmake /nologo clean)
457 elseif(CMAKE_GENERATOR STREQUAL "Ninja")
458 set(_clean_command ninja -t clean ${_target})
459 set(_clean_working_directory ${REACTOS_BINARY_DIR})
461 add_custom_target(${_target}_clean
462 COMMAND ${_clean_command}
463 WORKING_DIRECTORY ${_clean_working_directory}
464 COMMENT "Cleaning ${_target}")
468 function(add_library name)
469 _add_library(${name} ${ARGN})
470 add_clean_target(${name})
473 function(add_executable name)
474 _add_executable(${name} ${ARGN})
475 add_clean_target(${name})
477 elseif(USE_FOLDER_STRUCTURE)
478 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
479 string(LENGTH ${CMAKE_SOURCE_DIR} CMAKE_SOURCE_DIR_LENGTH)
481 function(add_custom_target name)
482 _add_custom_target(${name} ${ARGN})
483 string(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR_LENGTH} -1 CMAKE_CURRENT_SOURCE_DIR_RELATIVE)
484 set_property(TARGET "${name}" PROPERTY FOLDER "${CMAKE_CURRENT_SOURCE_DIR_RELATIVE}")
487 function(add_library name)
488 _add_library(${name} ${ARGN})
489 get_target_property(_target_excluded ${name} EXCLUDE_FROM_ALL)
490 if(_target_excluded AND ${name} MATCHES "^lib.*")
491 set_property(TARGET "${name}" PROPERTY FOLDER "Importlibs")
493 string(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR_LENGTH} -1 CMAKE_CURRENT_SOURCE_DIR_RELATIVE)
494 set_property(TARGET "${name}" PROPERTY FOLDER "${CMAKE_CURRENT_SOURCE_DIR_RELATIVE}")
498 function(add_executable name)
499 _add_executable(${name} ${ARGN})
500 string(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR_LENGTH} -1 CMAKE_CURRENT_SOURCE_DIR_RELATIVE)
501 set_property(TARGET "${name}" PROPERTY FOLDER "${CMAKE_CURRENT_SOURCE_DIR_RELATIVE}")
505 if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
506 macro(to_win_path _cmake_path _native_path)
507 string(REPLACE "/" "\\" ${_native_path} "${_cmake_path}")
510 # yeah the parameter mess sucks, but thats what works...
511 function(concatenate_files _file1 _target2 _output)
512 get_target_property(_file2 ${_target2} LOCATION)
513 to_win_path("${_file1}" _real_file1)
514 to_win_path("${_file2}" _real_file2)
515 to_win_path("${_output}" _real_output)
518 COMMAND cmd.exe /C "copy /Y /B ${_real_file1} + ${_real_file2} ${_real_output} > nul"
523 macro(concatenate_files _file1 _target2 _output)
524 get_target_property(_file2 ${_target2} LOCATION)
527 COMMAND cat ${_file1} ${_file2} > ${_output}
533 function(add_importlibs _module)
534 add_dependency_node(${_module})
536 if("${LIB}" MATCHES "msvcrt")
537 add_target_compile_definitions(${_module} _DLL __USE_CRTIMP)
538 target_link_libraries(${_module} msvcrtex)
540 target_link_libraries(${_module} lib${LIB})
541 add_dependencies(${_module} lib${LIB})
542 add_dependency_edge(${_module} ${LIB})
546 function(set_module_type MODULE TYPE)
547 cmake_parse_arguments(__module "UNICODE;HOTPATCHABLE" "IMAGEBASE" "ENTRYPOINT" ${ARGN})
549 if(__module_UNPARSED_ARGUMENTS)
550 message(STATUS "set_module_type : unparsed arguments ${__module_UNPARSED_ARGUMENTS}, module : ${MODULE}")
553 # Add the module to the module group list, if it is defined
554 if(DEFINED CURRENT_MODULE_GROUP)
555 set_property(GLOBAL APPEND PROPERTY ${CURRENT_MODULE_GROUP}_MODULE_LIST "${MODULE}")
558 # Set subsystem. Also take this as an occasion
559 # to error out if someone gave a non existing type
560 if((${TYPE} STREQUAL nativecui) OR (${TYPE} STREQUAL nativedll)
561 OR (${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver) OR (${TYPE} STREQUAL kerneldll))
562 set(__subsystem native)
563 elseif(${TYPE} STREQUAL win32cui)
564 set(__subsystem console)
565 elseif(${TYPE} STREQUAL win32gui)
566 set(__subsystem windows)
567 elseif(NOT ((${TYPE} STREQUAL win32dll) OR (${TYPE} STREQUAL win32ocx)
568 OR (${TYPE} STREQUAL cpl) OR (${TYPE} STREQUAL module)))
569 message(FATAL_ERROR "Unknown type ${TYPE} for module ${MODULE}")
572 if(DEFINED __subsystem)
573 set_subsystem(${MODULE} ${__subsystem})
576 #set unicode definitions
578 add_target_compile_definitions(${MODULE} UNICODE _UNICODE)
581 # Handle hotpatchable images.
582 # GCC has this as a function attribute so we're handling it using DECLSPEC_HOTPATCH
583 if(__module_HOTPATCHABLE AND MSVC AND (NOT ARCH STREQUAL "arm"))
584 set_property(TARGET ${MODULE} APPEND_STRING PROPERTY COMPILE_FLAGS " /hotpatch")
585 if(ARCH STREQUAL "i386")
586 set_property(TARGET ${MODULE} APPEND_STRING PROPERTY LINK_FLAGS " /FUNCTIONPADMIN:5")
587 elseif(ARCH STREQUAL "amd64")
588 set_property(TARGET ${MODULE} APPEND_STRING PROPERTY LINK_FLAGS " /FUNCTIONPADMIN:6")
593 if(__module_ENTRYPOINT OR (__module_ENTRYPOINT STREQUAL "0"))
594 list(GET __module_ENTRYPOINT 0 __entrypoint)
595 list(LENGTH __module_ENTRYPOINT __length)
596 if(${__length} EQUAL 2)
597 list(GET __module_ENTRYPOINT 1 __entrystack)
598 elseif(NOT ${__length} EQUAL 1)
599 message(FATAL_ERROR "Wrong arguments for ENTRYPOINT parameter of set_module_type : ${__module_ENTRYPOINT}")
602 elseif(${TYPE} STREQUAL nativecui)
603 set(__entrypoint NtProcessStartup)
605 elseif(${TYPE} STREQUAL win32cui)
607 set(__entrypoint wmainCRTStartup)
609 set(__entrypoint mainCRTStartup)
611 elseif(${TYPE} STREQUAL win32gui)
613 set(__entrypoint wWinMainCRTStartup)
615 set(__entrypoint WinMainCRTStartup)
617 elseif((${TYPE} STREQUAL win32dll) OR (${TYPE} STREQUAL win32ocx)
618 OR (${TYPE} STREQUAL cpl))
619 set(__entrypoint DllMainCRTStartup)
621 elseif((${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver))
622 set(__entrypoint DriverEntry)
624 elseif(${TYPE} STREQUAL nativedll)
625 set(__entrypoint DllMain)
627 elseif(${TYPE} STREQUAL module)
631 if(DEFINED __entrypoint)
632 if(DEFINED __entrystack)
633 set_entrypoint(${MODULE} ${__entrypoint} ${__entrystack})
635 set_entrypoint(${MODULE} ${__entrypoint})
640 if(__module_IMAGEBASE)
641 set_image_base(${MODULE} ${__module_IMAGEBASE})
642 elseif(${TYPE} STREQUAL win32dll)
643 if(DEFINED baseaddress_${MODULE})
644 set_image_base(${MODULE} ${baseaddress_${MODULE}})
646 message(STATUS "${MODULE} has no base address")
648 elseif((${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver) OR (${TYPE} STREQUAL kerneldll))
649 set_image_base(${MODULE} 0x00010000)
652 # Now do some stuff which is specific to each type
653 if((${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver) OR (${TYPE} STREQUAL kerneldll))
654 add_dependencies(${MODULE} bugcodes)
655 if((${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver))
656 set_target_properties(${MODULE} PROPERTIES SUFFIX ".sys")
660 if(${TYPE} STREQUAL win32ocx)
661 set_target_properties(${MODULE} PROPERTIES SUFFIX ".ocx")
664 if(${TYPE} STREQUAL cpl)
665 set_target_properties(${MODULE} PROPERTIES SUFFIX ".cpl")
668 # do compiler specific stuff
669 set_module_type_toolchain(${MODULE} ${TYPE})
672 function(start_module_group __name)
673 if(DEFINED CURRENT_MODULE_GROUP)
674 message(FATAL_ERROR "CURRENT_MODULE_GROUP is already set ('${CURRENT_MODULE_GROUP}')")
676 set(CURRENT_MODULE_GROUP ${__name} PARENT_SCOPE)
679 function(end_module_group)
680 get_property(__modulelist GLOBAL PROPERTY ${CURRENT_MODULE_GROUP}_MODULE_LIST)
681 add_custom_target(${CURRENT_MODULE_GROUP})
682 foreach(__module ${__modulelist})
683 add_dependencies(${CURRENT_MODULE_GROUP} ${__module})
685 unset(CURRENT_MODULE_GROUP PARENT_SCOPE)
688 function(preprocess_file __in __out)
690 foreach(__def in ${ARGN})
691 list(APPEND __arg -D${__def})
694 add_custom_command(OUTPUT ${_out}
695 COMMAND ${CMAKE_C_COMPILER} /EP ${__arg}
698 add_custom_command(OUTPUT ${_out}
699 COMMAND ${CMAKE_C_COMPILER} -E ${__arg}
704 function(get_includes OUTPUT_VAR)
705 get_directory_property(_includes INCLUDE_DIRECTORIES)
706 foreach(arg ${_includes})
707 list(APPEND __tmp_var -I${arg})
709 set(${OUTPUT_VAR} ${__tmp_var} PARENT_SCOPE)
712 function(get_defines OUTPUT_VAR)
713 get_directory_property(_defines COMPILE_DEFINITIONS)
714 foreach(arg ${_defines})
715 list(APPEND __tmp_var -D${arg})
717 set(${OUTPUT_VAR} ${__tmp_var} PARENT_SCOPE)
721 function(add_object_library _target)
722 add_library(${_target} OBJECT ${ARGN})
725 function(add_object_library _target)
726 add_library(${_target} ${ARGN})
731 set(ROSSYM_LIB "rossym")