Mercurial > archived > louis > epitech > mq > rathaxes
comparison maintainers_add_the_linux_kbuilddir_finder.patch @ 49:0c55f24c6b3d
Add a series of patch related to the build systme
author | Louis Opter <louis@lse.epitech.net> |
---|---|
date | Sun, 15 Jan 2012 21:36:15 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
48:7b377e31fea3 | 49:0c55f24c6b3d |
---|---|
1 # HG changeset patch | |
2 # Parent 6682d6e4330ef0429c41af6dcbe0362ff15d9841 | |
3 maintainers: add a CMake finder for the Linux build tree and only build the e1000 sample if it is found | |
4 | |
5 diff --git a/CMakeLists.txt b/CMakeLists.txt | |
6 --- a/CMakeLists.txt | |
7 +++ b/CMakeLists.txt | |
8 @@ -29,12 +29,17 @@ | |
9 | |
10 FIND_PACKAGE(LATEX) | |
11 FIND_PACKAGE(CodeWorker REQUIRED) | |
12 +FIND_PACKAGE(LinuxKBuildDir) | |
13 | |
14 INCLUDE(AddFileDependencies) | |
15 INCLUDE(FileCopy) | |
16 INCLUDE(RathaxesCopyLatexClasses) | |
17 INCLUDE(UseRathaxes) | |
18 | |
19 +IF (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT LINUX_KBUILD_DIR) | |
20 + MESSAGE(STATUS "No valid Linux build tree found, kernel modules will not be built") | |
21 +ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT LINUX_KBUILD_DIR) | |
22 + | |
23 # Global definitions ########################################################### | |
24 | |
25 ENABLE_TESTING() | |
26 diff --git a/maintainers/CMakeScripts/FindLinuxKBuildDir.cmake b/maintainers/CMakeScripts/FindLinuxKBuildDir.cmake | |
27 new file mode 100644 | |
28 --- /dev/null | |
29 +++ b/maintainers/CMakeScripts/FindLinuxKBuildDir.cmake | |
30 @@ -0,0 +1,41 @@ | |
31 +# Check if the kernel build directory exists | |
32 +# | |
33 +# This finder will seek for the usual /lib/modules/`uname -r`/build/ | |
34 +# directory. Obviously, this is Linux specific. | |
35 +# | |
36 +# You can specify an alternate build directory by using the environment | |
37 +# variable LINUX_KBUILD_DIR. | |
38 +# | |
39 +# This is necessary to build Linux kernel modules! | |
40 +# | |
41 +# Usage: FIND_PACKAGE(LinuxKBuildDir [REQUIRED]) | |
42 +# | |
43 +# This will set the variable LINUX_KBUILD_DIR with the path to the KBuild | |
44 +# directory, if it is found. | |
45 + | |
46 +IF (NOT LINUX_KBUILD_DIR) | |
47 + IF ($ENV{LINUX_KBUILD_DIR}) | |
48 + SET(KDIR $ENV{LINUX_KBUILD_DIR}) | |
49 + ELSE ($ENV{LINUX_KBUILD_DIR}) | |
50 + SET(KDIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build/") | |
51 + ENDIF ($ENV{LINUX_KBUILD_DIR}) | |
52 + | |
53 + IF (IS_DIRECTORY "${KDIR}") | |
54 + FIND_FILE(LINUX_KBUILD_DIR_MAKEFILE "Makefile" | |
55 + PATHS "${KDIR}" | |
56 + # Restrict the search to this directory only: | |
57 + NO_DEFAULT_PATH | |
58 + NO_CMAKE_ENVIRONMENT_PATH | |
59 + NO_CMAKE_PATH | |
60 + NO_SYSTEM_ENVIRONMENT_PATH | |
61 + NO_CMAKE_SYSTEM_PATH) | |
62 + # Check if it looks legit: | |
63 + IF (LINUX_KBUILD_DIR_MAKEFILE) | |
64 + SET(LINUX_KBUILD_DIR "${KDIR}" CACHE PATH "Path to the Linux KBuild directory (usually /lib/modules/`uname -r`/build/)") | |
65 + ENDIF (LINUX_KBUILD_DIR_MAKEFILE) | |
66 + ENDIF (IS_DIRECTORY "${KDIR}") | |
67 +ENDIF (NOT LINUX_KBUILD_DIR) | |
68 + | |
69 +INCLUDE(FindPackageHandleStandardArgs) | |
70 + | |
71 +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LinuxKBuildDir DEFAULT_MSG LINUX_KBUILD_DIR) | |
72 diff --git a/rathaxes/samples/e1000/CMakeLists.txt b/rathaxes/samples/e1000/CMakeLists.txt | |
73 --- a/rathaxes/samples/e1000/CMakeLists.txt | |
74 +++ b/rathaxes/samples/e1000/CMakeLists.txt | |
75 @@ -2,10 +2,6 @@ | |
76 RTI log.rti lkm.rti pci.rti socket.rti ethernet.rti e1000.rti | |
77 BLT log.blt lkm.blt pci.blt socket.blt ethernet.blt e1000.blt) | |
78 | |
79 -# We can't name lkm since it's already used as the target name to generate the | |
80 -# source (with ADD_RATHAXES_SOURCES). | |
81 - | |
82 -# does not work atm | |
83 -IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") | |
84 - ADD_RATHAXES_LKM(e1000 e1000_src) | |
85 -ENDIF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") | |
86 +IF (LINUX_KBUILD_DIR) | |
87 + ADD_RATHAXES_LKM(e1000 e1000_src) | |
88 +ENDIF (LINUX_KBUILD_DIR) |