Re: [CMake] SWIG python3

2012-03-12 Thread Matthias Fulz
Ok the error is related to my arch linux.
Cmake can't find python 3.2 because the lib is named "libpython3.2mu".
Does anybody know about this and perhaps has a solution?

On Mon, 2012-03-12 at 22:52 +0100, Matthias Fulz wrote:
> Hi,
> 
> I'm trying basic examples for using SWIG to generate python extensions
> for c++:
> 
> cmake_minimum_required(VERSION 2.8)
> 
> FIND_PACKAGE(SWIG REQUIRED)
> INCLUDE(${SWIG_USE_FILE})
> 
> FIND_PACKAGE(PythonLibs)
> INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
> 
> INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
> 
> SET(CMAKE_SWIG_FLAGS "")
> 
> SET_SOURCE_FILES_PROPERTIES(number.i PROPERTIES CPLUSPLUS ON)
> SET_SOURCE_FILES_PROPERTIES(number.i PROPERTIES SWIG_FLAGS
> "-includeall")
> SWIG_ADD_MODULE(number python
>   number.i number.hpp number.cpp)
> SWIG_LINK_LIBRARIES(number ${PYTHON_LIBRARIES})
> 
> This CMakeLists.txt is working fine, but only for python2, when I try to
> import it in python3, I'll receive the following error:
> 
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "number.py", line 26, in 
> _number = swig_import_helper()
>   File "number.py", line 22, in swig_import_helper
> _mod = imp.load_module('_number', fp, pathname, description)
> ImportError: dynamic module does not define init function
> (PyInit__number)
> 
> Could someone help me out here?
> 
> Thanks,
> 
> Matthias
> --
> 
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



signature.asc
Description: This is a digitally signed message part
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] SWIG python3

2012-03-12 Thread Matthias Fulz
Hi,

I'm trying basic examples for using SWIG to generate python extensions
for c++:

cmake_minimum_required(VERSION 2.8)

FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})

FIND_PACKAGE(PythonLibs)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

SET(CMAKE_SWIG_FLAGS "")

SET_SOURCE_FILES_PROPERTIES(number.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(number.i PROPERTIES SWIG_FLAGS
"-includeall")
SWIG_ADD_MODULE(number python
  number.i number.hpp number.cpp)
SWIG_LINK_LIBRARIES(number ${PYTHON_LIBRARIES})

This CMakeLists.txt is working fine, but only for python2, when I try to
import it in python3, I'll receive the following error:

Traceback (most recent call last):
  File "", line 1, in 
  File "number.py", line 26, in 
_number = swig_import_helper()
  File "number.py", line 22, in swig_import_helper
_mod = imp.load_module('_number', fp, pathname, description)
ImportError: dynamic module does not define init function
(PyInit__number)

Could someone help me out here?

Thanks,

Matthias


signature.asc
Description: This is a digitally signed message part
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Static lib in project

2012-01-15 Thread Matthias Fulz
On Sun, 2012-01-15 at 12:54 +0100, Eric Noulard wrote:
> 2012/1/15 Matthias Fulz :
> > It's working now - just had a typo inside the names.
> 
> ok fine.
> Just in case the "link_directories" call
> 
> link_directories(
>${CMAKE_BINARY_DIR}/src/testlib
>)
> 
Thank you for this hint, didn't know that I don't this.

is as stated by the documentation "rarely necessary."

> is as stated by the documentation "rarely necessary."
> and surely NOT necessary in your case.
> The target_link_libraries command should makes it
> possible to find the absolute path to the libraries.
> 
> This one is OK:
> include_directories(
>${CMAKE_SOURCE_DIR}/src/testlib
>)
> 
> 
Yes without that one, my programs weren't able to find
the headers without using full / relative paths.

Thank you




signature.asc
Description: This is a digitally signed message part
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Static lib in project

2012-01-14 Thread Matthias Fulz
It's working now - just had a typo inside the names.

Thanks @all.


On Sun, 2012-01-15 at 05:54 +0100, Matthias Fulz wrote:
> Have the following problem:
> 
> the lib is linked, but my testprogram can't link against it,
> because it's not found:
> 
> Built target
> aclibconfg
>   
>
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld:
>  cannot find -ltestlib
> collect2: ld returned 1 exit status
> make[2]: *** [src/test/test] Error 1
> make[1]: *** [src/test/CMakeFiles/test.dir/all] Error 2
> make[1]: *** Waiting for unfinished jobs
> 
> I've already added the directories to my target, but still not working:
> 
> src/test/CMakeLists.txt
> add_executable(test main.cpp)
> 
> link_directories(
> ${CMAKE_BINARY_DIR}/src/testlib
> )
> 
> include_directories(
> ${CMAKE_SOURCE_DIR}/src/testlib
> )
> 
> target_link_libraries(test testlib)
> 
> 
> The lib is build under src/testlib/testlib.a
> 
> Any help would be really nice !
> 
> BR,
> 
> Matthias
> 
> On Sat, 2012-01-14 at 23:42 +0100, Eric Noulard wrote:
> > src/CMakeList.txt
> > add_subdirectory(static_lib)
> > add_subdirectory(executable1)
> > add_subdirectory(executable2)
> > 
> > src/static_lib/CMakeLists.txt
> > add_library(InternalUse STATIC lib.cpp lib.hpp)
> > 
> > src/executable1/CMakeLists.txt
> > add_executable(exe1 main.cpp)
> > target_link_libraries(exe1 InternalUse)
> > install(TARGETS exe1 DESTINATION bin)
> > 
> > src/executable2/CMakeLists.txt
> > add_executable(exe2 main.cpp)
> > target_link_libraries(exe2 InternalUse)
> > install(TARGETS exe2 DESTINATION bin)
> > 
> > should work as expected.
> > 
> > "only inside this project" would mean
> > that you shouldn't install this library.
> > 
> 
> --
> 
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



signature.asc
Description: This is a digitally signed message part
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Static lib in project

2012-01-14 Thread Matthias Fulz
Have the following problem:

the lib is linked, but my testprogram can't link against it,
because it's not found:

Built target
aclibconfg  

   
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: 
cannot find -ltestlib
collect2: ld returned 1 exit status
make[2]: *** [src/test/test] Error 1
make[1]: *** [src/test/CMakeFiles/test.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs

I've already added the directories to my target, but still not working:

src/test/CMakeLists.txt
add_executable(test main.cpp)

link_directories(
${CMAKE_BINARY_DIR}/src/testlib
)

include_directories(
${CMAKE_SOURCE_DIR}/src/testlib
)

target_link_libraries(test testlib)


The lib is build under src/testlib/testlib.a

Any help would be really nice !

BR,

Matthias

On Sat, 2012-01-14 at 23:42 +0100, Eric Noulard wrote:
> src/CMakeList.txt
> add_subdirectory(static_lib)
> add_subdirectory(executable1)
> add_subdirectory(executable2)
> 
> src/static_lib/CMakeLists.txt
> add_library(InternalUse STATIC lib.cpp lib.hpp)
> 
> src/executable1/CMakeLists.txt
> add_executable(exe1 main.cpp)
> target_link_libraries(exe1 InternalUse)
> install(TARGETS exe1 DESTINATION bin)
> 
> src/executable2/CMakeLists.txt
> add_executable(exe2 main.cpp)
> target_link_libraries(exe2 InternalUse)
> install(TARGETS exe2 DESTINATION bin)
> 
> should work as expected.
> 
> "only inside this project" would mean
> that you shouldn't install this library.
> 



signature.asc
Description: This is a digitally signed message part
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] Static lib in project

2012-01-14 Thread Matthias Fulz
Hi,

could anybody give me a hint or an example on how to
use a static lib inside a project?

I need to create a static lib, which is only used inside
a project for different executables.

Let's say a project like the following:

src
  static_lib
lib.cpp
lib.hpp
  executable1
main.cpp
  executable2
main.cpp

The lib should be static and used only inside this project.

I hope I could make it clear :)

Thanks and best regards,

Matthias





signature.asc
Description: This is a digitally signed message part
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake