[CMake] nasm and TRY_COMPILE problem
Prakash Punnoor
prakash at punnoor.de
Thu Feb 23 13:22:13 EST 2006
Am Donnerstag Februar 23 2006 16:40 schrieb William A. Hoffman:
> At 10:43 AM 2/23/2006, Prakash Punnoor wrote:
> >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.
>
> It should run the link command directly.
Sorry, I don't understand what I should do to correct it.
>
> >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.
>
> Sometimes that is the only way to make sure something actually compiles and
> works.
Yes, but therefore we should better have a seperate command like
TRAY_COMPILE_AND_LINK or whatever.
> >This is now a major problem for me. I really don't want to work-around all
> >this troubles....
>
> You would have to post your files so that someone might be able to debug
> them.
Well, there was a link in the first post...but well, these are my current
files:
cat CMakeASMCompiler.cmake.in
SET(CMAKE_ASM_COMPILER "@CMAKE_ASM_COMPILER@")
SET(CMAKE_ASM_COMPILER_ARG1 "@CMAKE_ASM_COMPILER_ARG1@")
SET(CMAKE_ASM_COMPILER_LOADED 1)
SET(CMAKE_ASM_SOURCE_FILE_EXTENSIONS nasm;asm;nas)
SET(CMAKE_ASM_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
#SET(CMAKE_ASM_LINKER_PREFERENCE None)
IF(UNIX)
SET(CMAKE_ASM_OUTPUT_EXTENSION .o)
ELSE(UNIX)
SET(CMAKE_ASM_OUTPUT_EXTENSION .obj)
ENDIF(UNIX)
SET(CMAKE_ASM_COMPILER_ENV_VAR "ASM_COMPILER")
cat CMakeASMInformation.cmake
GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_ASM_COMPILER} NAME_WE)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
SET (CMAKE_ASM_FLAGS "$ENV{ASMFLAGS} ${CMAKE_ASM_FLAGS_INIT}" CACHE STRING
"Flags for ASM compiler.")
SET(CMAKE_INCLUDE_FLAG_ASM "-I")
IF(NOT CMAKE_ASM_COMPILE_OBJECT)
IF(UNIX)
SET(CMAKE_ASM_COMPILE_OBJECT
"<CMAKE_ASM_COMPILER> -f elf <FLAGS> -o <OBJECT> <SOURCE>")
ELSE(UNIX)
SET(CMAKE_ASM_COMPILE_OBJECT
"<CMAKE_ASM_COMPILER> -f win32 -DWIN32 <FLAGS> -o <OBJECT> <SOURCE>")
ENDIF(UNIX)
ENDIF(NOT CMAKE_ASM_COMPILE_OBJECT)
IF(NOT CMAKE_ASM_LINK_EXECUTABLE)
IF(UNIX)
SET(CMAKE_ASM_LINK_EXECUTABLE
"<CMAKE_ASM_COMPILER> -f elf <FLAGS> -o <OBJECT> <SOURCE>")
ELSE(UNIX)
SET(CMAKE_ASM_LINK_EXECUTABLE
"<CMAKE_ASM_COMPILER> -f win32 -DWIN32 <FLAGS> -o <OBJECT> <SOURCE>")
ENDIF(UNIX)
ENDIF(NOT CMAKE_ASM_LINK_EXECUTABLE)
MARK_AS_ADVANCED(
CMAKE_ASM_FLAGS
)
SET(CMAKE_ASM_INFOMATION_LOADED 1)
cat CMakeDetermineASMCompiler.cmake
IF(NOT CMAKE_ASM_COMPILER)
FIND_PROGRAM(CMAKE_ASM_COMPILER NAMES nasm)
ENDIF(NOT CMAKE_ASM_COMPILER)
MARK_AS_ADVANCED(CMAKE_ASM_COMPILER)
# configure variables set in this file for fast reload later on
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/admin/CMakeModules/CMakeASMCompiler.cmake.in
${CMAKE_BINARY_DIR}/CMakeFiles/CMakeASMCompiler.cmake
IMMEDIATE)
SET(CMAKE_ASM_COMPILER_ENV_VAR "ASM_COMPILER")
cat CMakeTestASMCompiler.cmake
# This file is used by EnableLanguage in cmGlobalGenerator to
# determine that that selected ASM compiler can actually compile
# and link the most basic of programs. If not, a fatal error
# is set and cmake stops processing commands and will not generate
# any makefiles or projects.
SET(CMAKE_ASM_COMPILER_WORKS 1 CACHE INTERNAL "")
Now try this in CMakeLists.txt.
Project(Test ASM C)
# 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
OUTPUT_VARIABLE OUTPUT)
BTW, the modules in CMAKE_ROOT contain this typo like above:
SET(CMAKE_ASM_INFOMATION_LOADED 1)
Shouldn't it be INFORMATION?
--
(°= =°)
//\ Prakash Punnoor /\\
V_/ \_V
More information about the CMake
mailing list