Boost python reliant

Je suis en ajoutant coup de pouce.python pour mon Jeu. J'écris des wrappers pour mes cours de les utiliser dans des scripts. Le problème est que la liaison de la bibliothèque de mon application. Je suis en utilisant cmake système de construction.

Maintenant, j'ai une application simple avec 1 fichier et le fichier makefile:

PYTHON = /usr/include/python2.7

BOOST_INC = /usr/include
BOOST_LIB = /usr/lib

TARGET = main

$(TARGET).so: $(TARGET).o
    g++ -shared -Wl,--export-dynamic \
    $(TARGET).o -L$(BOOST_LIB) -lboost_python \
    -L/usr/lib/python2.7/config -lpython2.7 \
    -o $(TARGET).so

$(TARGET).o: $(TARGET).cpp
    g++ -I$(PYTHON) -I$(BOOST_INC) -c -fPIC $(TARGET).cpp

Et cela fonctionne. Il construit un ' fichier pour moi qui je peux importer à partir de python.

Maintenant la question: comment obtenir ce pour cmake?

Je l'ai écrit dans principal CMakeList.txt:

...
find_package(Boost COMPONENTS filesystem system date_time python REQUIRED)
message("Include dirs of boost: " ${Boost_INCLUDE_DIRS} )
message("Libs of boost: " ${Boost_LIBRARIES} )

include_directories(
    ${Boost_INCLUDE_DIRS}
        ...
)

target_link_libraries(Themisto
    ${Boost_LIBRARIES}
    ...
)
...

message appels spectacle:

Include dirs of boost: /usr/include
Libs of boost: /usr/lib/libboost_filesystem-mt.a/usr/lib/libboost_system-mt.a/usr/lib/libboost_date_time-mt.a/usr/lib/libboost_python-mt.a

Ok, donc je l'ai ajouté .fichier cpp pour mon projet, avec notamment de <boost/python.hpp>. J'obtiens une erreur à la compilation:

/usr/include/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such file or directory

Pour ne pas prendre tous besoin d'inclure des répertoires.

Et deuxième question:

Comment organiser 2-l'étape de construction de script-fichiers cpp? Dans le makefile, j'ai montré il y a CIBLE.o et CIBLE.donc, la façon de traiter que 2 commandes dans cmake?

Que je comprends, le meilleur moyen est de créer un sous-projet et de faire quelque chose là.

Grâce.

OriginalL'auteur Max Frai | 2011-03-08