2

I have a custom target:

 add_custom_target(
      create-po
      COMMAND ${MSGINIT} --no-translator -i "${PROJECT_SOURCE_DIR}/data/${PACKAGE}.pot" - "${PROJECT_SOURCE_DIR}/po/es.po" -l es_MX.utf8
 )

so, is invoked like this:

 # make create-po

my idea is to change it to something like this:

 # make create-po "es"

so, any user can create a custom localed po file. I don't know the word exactly for this, but I'd like to add a parameter in the target name..is it posible with cmake? Thanks

Joel
  • 1,805
  • 1
  • 22
  • 22
  • 1
    I don't know about the cmake part of this question but make itself cannot take arguments like that as such. It would need to be something like `make create-po POLANG=es` or something like that to work I believe. – Etan Reisner May 05 '14 at 18:08
  • Why not just generate targets with names like `create-po-${lang}` and then run `make create-po-es`? With a bit of imagination, the `-es` part is just like a parameter. – arrowd May 07 '14 at 06:03
  • I like your idea, arrowdodger, but I want any user can create their own PO file. If I follow your idea, the end user must edit configure.ac or Makefile.am to generate the appropiate target. – Joel May 07 '14 at 17:51
  • I doubt you can do it because cmake can be used with different generators (like visual studio), hence I think you need some more general concept, e.g. environment variable. –  May 13 '14 at 10:55

1 Answers1

0

After so long time I found this question for the same reason: Can I use CMake to initialize a .po file if I want to add a new translation? I expect to use it only once in a while for my project, so make the build system do it seems more comfortable to me than find out all the required options and paths every time.

I ended up with the following CMake snippet:

set(INIT_LANG CACHE STRING "give a locale here to create a target which initializes a related .po file")
IF(INIT_LANG)
  add_custom_target(
    create-po-${INIT_LANG}
    ... # integrate INIT_LANG in your command
  )
ENDIF(INIT_LANG)

Then, if you want to initialize a new translation file, call (assuming your build dir in under the project root):

# cmake -DINIT_LANG=es_MX.utf8 ..

... and you should get a corresponding make target:

# make create-po-es_MX.utf8

Yes, it's not as straight-forward as the OP's idea/expectation (and mine as well), but users can create new .po files by themselves (of course, this will be documented properly for them in the project ;) ).

user2169513
  • 172
  • 1
  • 1
  • 11