[CMake] nasm and TRY_COMPILE problem

Prakash Punnoor prakash at punnoor.de
Thu Feb 23 10:43:29 EST 2006


Am Sonntag Februar 19 2006 22:30 schrieb Prakash Punnoor:
> Hi,
>
> I am using these files to get nasm support:
> http://www.cmake.org/pipermail/cmake/2005-November/007478.html
>
> This works for compilation, but recently I wanted to make a test using
> TRY_COMPILE like this:
>
>       # check nasm visibility support
>       SET(SOURCE "global _foo:function hidden")
>       FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/src.nasm" "${SOURCE}")
>
>       TRY_COMPILE(NASM_HAS_VISIBILITY
>                   ${CMAKE_BINARY_DIR}
>                   ${CMAKE_BINARY_DIR}/CMakeTmp/src.nasm
>                   CMAKE_FLAGS
>                   OUTPUT_VARIABLE OUTPUT)
>
> But I get:
>
> CMake Error: CMAKE_ASM_COMPILER not set, after EnableLanguage
> CMake Error: Internal CMake error, TryCompile configure of cmake failed
>
> What have I forgotton? I notice that despite the line
>
> CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/admin/CMakeModules/CMakeASMCompiler.cmak
>e.in ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeASMCompiler.cmake IMMEDIATE @ONLY)
>
> in CMakeDetermineASMCompiler.cmake the file doesn't get created (at least I
> don't find it). But if I leave out that line, CMake errors. I don't know
> whether this is related to above problem.
>
>
> I am using cmake version 2.2-patch 3.

OK, I found one fault of myself and one possible bug in CMake:

- I forgot an CMakeTestASMCompiler.cmake file. I added it containing this 
line:
SET(CMAKE_ASM_COMPILER_WORKS 1 CACHE INTERNAL "")

- I needed to add the variable CMAKE_ASM_LINK_EXECUTABLE in 
CMakeASMInformation.cmake. (It contaisn the same as the compile objects line, 
so it is just faking.)

If I now try above code, the CONFIGURE_FILE command actually creates the 
wanted file in CMakeFiles, but I get this:


CMake Error: Error required internal CMake variable not set, cmake may be not 
be built correctly.
Missing variable is:
CMAKE_ASM_COMPILE_OBJECT
CMake Error: Error required internal CMake variable not set, cmake may be not 
be built correctly.
Missing variable is:
CMAKE_ASM_LINK_EXECUTABLE
CMake Error: Internal CMake error, TryCompile generation of cmake failed

But, if I copy my 4 files for nasm integration from my project module dir into 
CMAKE_ROOT (and adjusting the path in the CONFIGURE_FILE command) it works! 
So this seems to be a bug in cmake.

Currently I am using the cvs version and experience above. (cmake version 
2.3-20060223)

Now another question: nasm cannot link code, so what should I write into 
CMAKE_ASM_LINK_EXECUTABLE? It should use the default c/c++/whatever linker.

Why does TRY_COMPILE not only compile but also try to link the code? Actually 
compilng only would be enough to run most tests and would also be a bit 
faster if you avoid linking.

This is now a major problem for me. I really don't want to work-around all 
this troubles....

Cheers,
-- 
(°=                 =°)
//\ Prakash Punnoor /\\
V_/                 \_V


More information about the CMake mailing list