[CMake] NMake Makefiles, 2.4.4 and target link libraries
Patrick J. Franz -- ML
patrick at xia.com
Wed Nov 29 13:33:25 EST 2006
Bill Hoffman wrote:
> Can you create a working example of this that shows the problem? I have
> tried a few things, but am unable to see the problem.
Below is a working example on my machine -- hopefully you will see the
same results as me:
> Microsoft (R) Program Maintenance Utility Version 6.00.9782.0
> Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
>
> -- Configuring done
> -- Generating done
> -- Build files have been written to: f:/XIA Software/cmake_bug_test
> Scanning dependencies of target my_library_dep
> [ 50%] Building C object
CMakeFiles/my_library_dep.dir/src/my_library_dep.obj
> my_library_dep.c
> Linking C shared library lib\my_library_dep.dll
> Creating library lib\my_library_dep.lib and object
lib\my_library_dep.exp
> [ 50%] Built target my_library_dep
> Linking C shared library lib\my_library.dll
> LINK : fatal error LNK1104: cannot open file "lib/my_library_dep.dll.lib"
> NMAKE : fatal error U1077: 'link' : return code '0x450'
> Stop.
> NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual
Studio\VC98\bin\NMAKE.EXE"' : return code '0x2'
> Stop.
> NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual
Studio\VC98\bin\nmake.exe"' : return code '0x2'
> Stop.
I generated my Makefile running `cmake -G "NMake Makefiles" .` followed
by `nmake`. The compiler is VS6.
Directory structure:
my_project/CMakeLists.txt
my_project/cmake/my_library_dep.cmake
my_project/cmake/my_library.cmake
my_project/src/my_library_dep.h
my_project/src/my_library_dep.c
my_project/src/my_library.c
my_project/t_api
my_project/lib
my_project/CMakeLists.txt
-------------------------
project(my_project C)
set(LIBRARY_OUTPUT_PATH lib)
include_directories(src)
link_directories(lib)
include(cmake/my_library_dep.cmake)
include(cmake/my_library.cmake)
my_project/cmake/my_library_dep.cmake
-------------------------------------
add_library(my_library_dep SHARED src/my_library_dep.c)
set(my_library_dep_lib_name
${CMAKE_SHARED_LIBRARY_PREFIX}my_library_dep${CMAKE_SHARED_LIBRARY_SUFFIX})
add_custom_command(TARGET my_library_dep POST_BUILD
COMMAND cmake -E copy
ARGS lib/${my_library_dep_lib_name} t_api/${my_library_dep_lib_name})
my_project/cmake/my_library.cmake
---------------------------------
add_library(my_library SHARED src/my_library.c)
target_link_libraries(my_library my_library_dep)
set(my_library_lib_name
${CMAKE_SHARED_LIBRARY_PREFIX}my_library${CMAKE_SHARED_LIBRARY_SUFFIX})
add_custom_command(TARGET my_library POST_BUILD
COMMAND cmake -E copy
ARGS lib/${my_library_lib_name} t_api/${my_library_lib_name})
my_project/src/my_library_dep.h
-------------------------------
__declspec(dllimport) void func(int arg);
my_project/src/my_library_dep.c
-------------------------------
__declspec(dllexport) void func(int arg);
__declspec(dllexport) void func(int arg)
{
arg = 23;
}
my_project/src/my_library.c
---------------------------
#include "my_library_dep.h"
__declspec(dllexport) void other_func(int arg);
__declspec(dllexport) void other_func(int arg)
{
func(arg);
}
Best Regards,
Patrick
More information about the CMake
mailing list