3 include_directories(BEFORE ${REACTOS_SOURCE_DIR}/include/c++/stlport)
6 -DNATIVE_CPP_INCLUDE=${REACTOS_SOURCE_DIR}/include/c++
7 -DNATIVE_C_INCLUDE=${REACTOS_SOURCE_DIR}/include/crt)
10 function(add_dependency_node _node)
11 if(GENERATE_DEPENDENCY_GRAPH)
12 get_target_property(_type ${_node} TYPE)
13 if(_type MATCHES SHARED_LIBRARY OR ${_node} MATCHES ntoskrnl)
14 file(APPEND ${REACTOS_BINARY_DIR}/dependencies.graphml " <node id=\"${_node}\"/>\n")
19 function(add_dependency_edge _source _target)
20 if(GENERATE_DEPENDENCY_GRAPH)
21 get_target_property(_type ${_source} TYPE)
22 if(_type MATCHES SHARED_LIBRARY)
23 file(APPEND ${REACTOS_BINARY_DIR}/dependencies.graphml " <edge source=\"${_source}\" target=\"${_target}\"/>\n")
28 function(add_dependency_header)
29 file(APPEND ${REACTOS_BINARY_DIR}/dependencies.graphml "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<graphml>\n <graph id=\"ReactOS dependencies\" edgedefault=\"directed\">\n")
32 function(add_dependency_footer)
33 add_dependency_node(ntdll)
34 file(APPEND ${REACTOS_BINARY_DIR}/dependencies.graphml " </graph>\n</graphml>\n")
37 function(add_message_headers)
38 foreach(_in_FILE ${ARGN})
39 get_filename_component(FILE ${_in_FILE} NAME_WE)
42 OUTPUT ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.rc ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.h
44 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.mc)
45 set_source_files_properties(
46 ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.h ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.rc
47 PROPERTIES GENERATED TRUE)
48 add_custom_target(${FILE} ALL DEPENDS ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.h ${REACTOS_BINARY_DIR}/include/reactos/${FILE}.rc)
52 macro(dir_to_num dir var)
53 if(${dir} STREQUAL reactos/system32)
55 elseif(${dir} STREQUAL reactos/system32/drivers)
57 elseif(${dir} STREQUAL reactos/Fonts)
59 elseif(${dir} STREQUAL reactos)
61 elseif(${dir} STREQUAL reactos/system32/drivers/etc)
63 elseif(${dir} STREQUAL reactos/inf)
65 elseif(${dir} STREQUAL reactos/bin)
67 elseif(${dir} STREQUAL reactos/media)
70 message(ERROR "Wrong destination: ${dir}")
75 cmake_parse_arguments(_CD "NO_CAB" "DESTINATION;NAME_ON_CD;TARGET" "FILE;FOR" ${ARGN})
76 if(NOT (_CD_TARGET OR _CD_FILE))
77 message(FATAL_ERROR "You must provide a target or a file to install!")
80 if(NOT _CD_DESTINATION)
81 message(FATAL_ERROR "You must provide a destination")
82 elseif(${_CD_DESTINATION} STREQUAL root)
83 set(_CD_DESTINATION "")
87 message(FATAL_ERROR "You must provide a cd name (or "all" for all of them) to install the file on!")
90 #get file if we need to
92 get_target_property(_CD_FILE ${_CD_TARGET} LOCATION)
95 #do we add it to all CDs?
96 if(_CD_FOR STREQUAL all)
97 set(_CD_FOR "bootcd;livecd;regtest")
100 #do we add it to bootcd?
101 list(FIND _CD_FOR bootcd __cd)
102 if(NOT __cd EQUAL -1)
103 #whether or not we should put it in reactos.cab or directly on cd
106 foreach(item ${_CD_FILE})
107 file(APPEND ${REACTOS_BINARY_DIR}/boot/bootcd.cmake "file(COPY \"${item}\" DESTINATION \"\${CD_DIR}/${_CD_DESTINATION}\")\n")
110 get_filename_component(__file ${_CD_FILE} NAME)
111 #rename it in the cd tree
112 file(APPEND ${REACTOS_BINARY_DIR}/boot/bootcd.cmake "file(RENAME \${CD_DIR}/${_CD_DESTINATION}/${__file} \${CD_DIR}/${_CD_DESTINATION}/${_CD_NAME_ON_CD})\n")
116 add_dependencies(bootcd ${_CD_TARGET})
119 #add it in reactos.cab
120 dir_to_num(${_CD_DESTINATION} _num)
121 if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
122 file(APPEND ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.dff.dyn "${_CD_FILE} ${_num}\n")
124 file(APPEND ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.dff.dyn "\"${_CD_FILE}\" ${_num}\n")
128 add_dependencies(reactos_cab ${_CD_TARGET})
133 #do we add it to livecd?
134 list(FIND _CD_FOR livecd __cd)
135 if(NOT __cd EQUAL -1)
138 add_dependencies(livecd ${_CD_TARGET})
140 foreach(item ${_CD_FILE})
141 file(APPEND ${REACTOS_BINARY_DIR}/boot/livecd.cmake "file(COPY \"${item}\" DESTINATION \"\${CD_DIR}/${_CD_DESTINATION}\")\n")
144 get_filename_component(__file ${_CD_FILE} NAME)
145 #rename it in the cd tree
146 file(APPEND ${REACTOS_BINARY_DIR}/boot/livecd.cmake "file(RENAME \${CD_DIR}/${_CD_DESTINATION}/${__file} \${CD_DIR}/${_CD_DESTINATION}/${_CD_NAME_ON_CD})\n")
150 #do we add it to regtest?
151 list(FIND _CD_FOR regtest __cd)
152 if(NOT __cd EQUAL -1)
153 #whether or not we should put it in reactos.cab or directly on cd
156 foreach(item ${_CD_FILE})
157 file(APPEND ${REACTOS_BINARY_DIR}/boot/bootcdregtest.cmake "file(COPY \"${item}\" DESTINATION \"\${CD_DIR}/${_CD_DESTINATION}\")\n")
160 get_filename_component(__file ${_CD_FILE} NAME)
161 #rename it in the cd tree
162 file(APPEND ${REACTOS_BINARY_DIR}/boot/bootcdregtest.cmake "file(RENAME \${CD_DIR}/${_CD_DESTINATION}/${__file} \${CD_DIR}/${_CD_DESTINATION}/${_CD_NAME_ON_CD})\n")
166 add_dependencies(bootcdregtest ${_CD_TARGET})
169 #add it in reactos.cab
170 #dir_to_num(${_CD_DESTINATION} _num)
171 #file(APPEND ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.dff.dyn "${_CD_FILE} ${_num}\n")
174 # add_dependencies(reactos_cab ${_CD_TARGET})
180 # Create module_clean targets
181 function(add_clean_target target)
182 if(CMAKE_GENERATOR MATCHES "Unix Makefiles" OR CMAKE_GENERATOR MATCHES "MinGW Makefiles")
183 set(CLEAN_COMMAND make clean)
184 elseif(CMAKE_GENERATOR MATCHES "NMake Makefiles")
185 set(CLEAN_COMMAND nmake clean)
187 add_custom_target(${target}_clean
188 COMMAND ${CLEAN_COMMAND}
189 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
190 COMMENT "Cleaning ${target}")
194 function(add_library name)
195 _add_library(${name} ${ARGN})
196 add_clean_target(${name})
199 function(add_executable name)
200 _add_executable(${name} ${ARGN})
201 add_clean_target(${name})
205 if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
206 macro(to_win_path _cmake_path _native_path)
207 string(REPLACE "/" "\\" ${_native_path} "${_cmake_path}")
210 function(concatenate_files _file1 _file2 _output)
211 to_win_path("${_file1}" _real_file1)
212 to_win_path("${_file2}" _real_file2)
213 to_win_path("${_output}" _real_output)
216 COMMAND cmd.exe /C "copy /Y /B ${_real_file1} + ${_real_file2} ${_real_output} > nul"
221 macro(concatenate_files _file1 _file2 _output)
224 COMMAND cat ${_file1} ${_file2} > ${_output}
230 macro(add_importlibs MODULE)
231 add_dependency_node(${MODULE})
233 if ("${LIB}" MATCHES "msvcrt")
234 add_definitions(-D_DLL -D__USE_CRTIMP)
235 target_link_libraries(${MODULE} msvcrtex)
237 target_link_libraries(${MODULE} ${CMAKE_BINARY_DIR}/importlibs/lib${LIB}${CMAKE_STATIC_LIBRARY_SUFFIX})
238 add_dependencies(${MODULE} lib${LIB})
239 add_dependency_edge(${MODULE} ${LIB})