[CMake] Avoid nested cmake invocation taking parent's info.
Eric NOULARD
eric.noulard at gmail.com
Sun Nov 9 17:26:32 EST 2008
Le Sun, 09 Nov 2008 22:24:45 +0100,
Óscar Fuentes <ofv at wanadoo.es> a écrit :
> While cross-compiling, I'm trying to avoid depending on previously
> built executables, that is, the cross-compile build should create the
> native utilities it needs. For this, I'm trying
>
> execute_process(
> COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release
> ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CX_NATIVE_TG_DIR}
> )
>
> where CX_NATIVE_TG_DIR is a new directory where the native build is
> performed. Later,
>
> add_custom_command(OUTPUT ${LLVM_TABLEGEN}
> COMMAND ${CMAKE_BUILD_TOOL} -C ${CX_NATIVE_TG_DIR}/utils/TableGen
> COMMENT "Building native TableGen...")
> add_custom_target(NativeTableGen DEPENDS ${LLVM_TABLEGEN})
>
> The problem is in execute_process. The cmake process created by it is
> taking variable values from the enclosing cmake, so it uses the same
> compiler, configure variables, etc.
What do you mean by "variables"?
CMake one or
Environment one?
I would say that environment may be inherited but not CMake one?
Is this the case?
(I have no experience of cross-compiling with CMake).
> How can this be avoided? I want the nested cmake to work as if the
> enclosing cmake didn't existed.
May be it would be possible to "reset" the cross-compile
setup using appropriate CMAKE_TOOLCHAIN_FILE?
Or you may reverse your scheme,
Always run a "native" build for building native tool
and make the native build invoke the Cross build using
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} CMAKE_TOOLCHAIN_FILE=
...
)
--
Erk
More information about the CMake
mailing list