[Cmake] How to change the default output file name for
libraries in Linux
William A. Hoffman
billlist at nycap.rr.com
Thu, 08 Apr 2004 09:17:26 -0400
I have created cmake files for swig, you can find them here:
ftp:/public.kitware.com/pub/cmake/contrib/SwigCMake.6.tar.gz.
It requires cvs cmake to run the swig tests, but you should
be able to use most of the basic swig stuff from cmake if you look
at the CMake directory in that tar file.
For creating a library from swig I use this macro:
MACRO(ADD_SWIG_LIBRARY LANGUAGE LIBNAME SOURCES)
SET(SWIG_LIB_PREFIX "")
IF("${LANGUAGE}" MATCHES "^python$")
SET(SWIG_LIB_PREFIX "_")
ENDIF("${LANGUAGE}" MATCHES "^python$")
# tcl does not use MODULES
IF("${LANGUAGE}" MATCHES "^tcl$")
ADD_LIBRARY("${SWIG_LIB_PREFIX}${LIBNAME}" SHARED ${SOURCES})
ELSE("${LANGUAGE}" MATCHES "^tcl$")
ADD_LIBRARY("${SWIG_LIB_PREFIX}${LIBNAME}" MODULE ${SOURCES})
ENDIF("${LANGUAGE}" MATCHES "^tcl$")
IF(${LANGUAGE} MATCHES "java")
ELSE(${LANGUAGE} MATCHES "java")
SET_TARGET_PROPERTIES("${SWIG_LIB_PREFIX}${LIBNAME}" PROPERTIES PREFIX "")
ENDIF(${LANGUAGE} MATCHES "java")
IF(SWIG_SOURCE_DIR)
IF(CMAKE_CONFIGURATION_TYPES)
ADD_DEPENDENCIES("${SWIG_LIB_PREFIX}${LIBNAME}" swig)
ENDIF(CMAKE_CONFIGURATION_TYPES)
ENDIF(SWIG_SOURCE_DIR)
ENDMACRO(ADD_SWIG_LIBRARY)
At 05:26 AM 4/8/2004, Raghavendra Chandrashekara wrote:
>I tried putting ADD_LIBRARY(mymodule MODULE ...) in the CMakeLists.txt file but the target still has a lib prefix. What I am trying to do is create a module for python using swig. But in the wrapper python code generated by swig, the first line reads:
>
>import _mymodule
>
>so the library needs to be called _mymodule.so. Will I have to manually rename the files my self?
>
>Thanks,
>
>Raghavendra
>
>PS. Will swig be supported in any upcoming releases of CMake?
>
>William A. Hoffman wrote:
>
>>There are some OS issues here. For UNIX, to link with -lmylibrary, the
>>library must be libmylibrary.so. For win32 dll's, the library must be mylibrary.dll and mylibrary.lib, but cmake should not add a lib infront.
>>If this is a loadable module and not really a library, then you might want to
>>try ADD_LIBRARY(mymodule MODULE ...)
>>
>>-Bill
>>
>>
>>At 02:02 PM 4/7/2004, Raghavendra Chandrashekara wrote:
>>
>>
>>>Hi,
>>>
>>>Is there a way to change the default library name for the ADD_LIBRARY(mylibrary SHARED ${mylibrary_SOURCES}) command. I want to create a library which is called mylibrary.dll and not libmylibrary.dll
>>>
>>>Thanks,
>>>
>>>Raghavendra
>>>
>>>_______________________________________________
>>>Cmake mailing list
>>>Cmake at www.cmake.org
>>>http://www.cmake.org/mailman/listinfo/cmake
>>>
>>
>>
>