Hi Trevor, On Sunday 20 May 2007 18:13, Trevor Kellaway wrote: > Hi CMake developers, > > I've been trying to modify my previous cross compiler support work to > fit into the new development scheme of tool chain support with > CMAKE_TOOLCHAIN_FILE that is in the current development CVS tree.
nice, I wanted to invite you to test the changes (including documentation) but apparently you were faster :-) ------------------------------------- So in the toolchain file you have to set - CMAKE_C_COMPILER - e.g. ppc_74xx-gcc - CMAKE_SYSTEM_NAME - e.g. "Linux" --------------------------------- You probably need to set: CMAKE_FIND_ROOT_PATH = <path to your target environment> This can be a list of directories and cmake will use these as prefix for find_xxx() commands. You can adjust the behaviour of find_program(), find_library() and find_path() separately. By default at first all directories are searched with the paths as prefix and after that without the prefix. This will usually find what you want. But you probably will want to set the following: # find_program should (by default) NEVER search in the target tree, but only # in the host tree SET(CMAKE_FIND_ROOT_MODE_PROGRAM NEVER) # both find_library() and find_path() should (by default) # search ONLY in the target tree SET(CMAKE_FIND_ROOT_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_MODE_INCLUDE ONLY) You can adjust the behaviour in every find_xxx() call separately with the NO_CMAKE_FIND_ROOT_PATH, ONLY_CMAKE_FIND_ROOT_PATH and CMAKE_FIND_ROOT_PATH_BOTH options. ------------------------- In the toolchain file you can also set -CMAKE_SYSTEM_INFO_FILE - there you can adjust compiler flags, commands etc. if you are using a compiler unsupported by cmake -CMAKE_C_OUTPUT_EXTENSION and CMAKE_CXX_OUTPUT_EXTENSION if they are not ".o" or ".obj" -CMAKE_SYSTEM_VERSION (not used a lot) -CMAKE_CXX_COMPILER (should be found automatically if you specify the C compiler) This is a first try and the API may still change, also depending on your input. Please let me know what you think. > I've defined CMAKE_TOOLCHAIN_FILE to point at my tool chain specific > cross compiler information, including compiler flags etc. > > To make CMake configure successfully I had to define the following: > > -DCMAKE_TOOLCHAIN_FILE:string=Toolchain-Freescale-HC12 (1) > -DCMAKE_C_COMPILER_ID_RUN:bool=TRUE (2) > -DCMAKE_C_COMPILER_WORKS:bool=TRUE (3) > > (1) Does anyone have a proposed convention for naming extension tool > chains? I would suggest "Toolchain-<Vendor>-<Arch>" Personally I think that there are so many slightly different toolchains out there for cross compiling, that these files won't be part of cmake, and so I don't see a big need for a convention for naming these files. Additionally to what you suggest the name should contain the host and the target platform. For some architectures there will be the need to add more details to the name. This would give something like e.g. Linux2Linux-gcc-denx-arm-softfloat.cmake, which is quite verbose. > Is the intention that I should have to define (2) and (3)? No. > It would be > nicer to have a cleaner way to turn of the compiler self-testing which > is being caused by trying to determine the compiler ID, I would assume > this is the intention of CMAKE_CROSSCOMPILING which doesn't seem to be > being used anywhere yet? No. You can use CMAKE_CROSSCOMPILING in your cmake files to check whether you are crosscompiling and it is used in TRY_RUN() if you try to run a cross-compiled executable. The tests for the compiler id and c compiler works should also work with a cross compiler. Can you send me the error log or the complete CMakeFiles/ directory for such a failed cmake run ? The test for sizeof void will currently not work, as a work around you should set it directly: SET (CMAKE_SIZEOF_VOID_P 4 CACHE INTERNAL "Size of void* data type") This will be fixed soon. Is this a gcc ? Can I download the toolchain somewhere ? Bye Alex
# what't the target system ? set(CMAKE_SYSTEM_NAME Windows) # which compiler to use set(CMAKE_C_COMPILER i586-mingw32msvc-gcc) # where are the target libraries and headers installed ? set(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc;/tmp ) # find_program() should by default NEVER search in the target tree SET(CMAKE_FIND_ROOT_MODE_PROGRAM NEVER) # whereas find_library() and find_path() should be default search ONLY in the target tree SET(CMAKE_FIND_ROOT_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_MODE_INCLUDE ONLY) # sizeof(void) currently doesn't work for crosscompiling, use this to keep it from running SET (CMAKE_SIZEOF_VOID_P 4 CACHE INTERNAL "Size of void* data type") # needed for mingw set(CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_SYSTEM_LIBRARY_PATH} /lib ) set(CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_SYSTEM_INCLUDE_PATH} /include )
_______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake