[CMake] specific target to gettext
Hendrik Sattler
post at hendrik-sattler.de
Tue Jul 28 03:20:39 EDT 2009
Hi,
please don't top-post.
Zitat von alexis lameire <alexisis-pristontale at hotmail.com>:
> grumf :/
> i have try this, can you help me to look what that don't match
> http://pastie.org/561035
>
> he don't compile the po file :/ and i don't found the mo target dependancies
You do lot's of things wrong there:
include(FindGettext)
find_package(Gettext)
is not correct: delete the include() line.
link_directories(
${USE_gcrypt_LIBRARY}
${USE_glib2_LIBRARY}
${USE_ircclient_LIBRARY}
${SQLITE_LIBRARIES}
)
is most certainly not the right thing to do. It is not possible to
look into the values of the variables but the probably contain file
paths not directories. Link_directories() is no necessary if libraries
are given with full path!
target_link_libraries(
d7c
${LIBRARIES}
sqlite3
)
Why are you using "sqlite3" here and not "${SQLITE_LIBRARIES}" from above?
add_custom_target(
update_pot
COMMAND xgettext -d ${package_name} -s -o
${package_name}.pot ./src/*.c -p ./po
--from-code=utf-8 -j
--keyword=_
--package-name=${package_name}
--package-version=${package_version}
--msgid-bugs-address=${email_report}
)
You are missing the dependency on the source files here. You should
not list them as src/*.c, instead use the ones from the d7c target.
You should also use full path names (variables for current build and
current source directory exist) for input and output files. Since you
create the .pot file on every build, you should not create it in the
source directory but in the build directory instead. (but see below)
add_custom_command(
TARGET update_pot
COMMAND msgmerge --update ${po_files} ./po/${package_name}.pot
)
You are missing the dependency on the pot file here.
Additionally, you pollute the source directory with changed files on
every build :-(
Additionally, msgmerge can only handle _one_ .po file at a time.
You should also use full path names (variables for current build and
current source directory exist). Same for also all others command.
(but see below)
#ajout d'un fichier po
add_custom_target(
create_po
COMMAND msginit -l $(LANGUAGE) -o ./po/$(LANGUAGE).po -i
./po/${package_name}.pot
)
What if the .po file already exists. You will overwrite in in this
case: not good. The dependency on the .pot file is missing. (see below)
Generally:
1.
list all files that you use as dependencies to make it work. Else,
make (not cmake) cannot determine the build order automatically and
will eventually fail.
2.
Don't make it yourself too easy by using file(GLOB ....). That is not
a good approach. It will give you major pain if you want to e.g.
exlude some files from the build.
3. Don't create the .pot file on every build and don't merge it in the
.po files as that always needs manual work afterwards. If it doesn't,
then the two command were no-ops anyway. So: xgettext, msgmerge and
msginit are a totally separate task that you do not need at
build-time. Instead, they should be part of the development process,
not of the build process.
So the only thing left is msgfmt. And that one is easy.
HS
More information about the CMake
mailing list