title: include lua library in kreversi using cmake (kdegames)
body: <p>So, i'm working on adding lua script into <a href="http://games.kde.org/game.php?game=kreversi" rel="nofollow">kreversi</a>. I am a newbie on cmake and this is my first time trying to code into kde projects. </p>
  
  <p>I'm using lua5.2 and found out that cmake doesnt officially support lua5.2 library. So i searched and found <a href="https://github.com/beoran/eruta/blob/master/cmake/FindLua52.cmake" rel="nofollow">this cmake</a> for lua5.2 and imitate his or her CMakeList.txt and modified accordingly to the kreversi CMakeList.txt.</p>
  
  <p>here is my modified kreversi CMakeList : </p>
  
  <pre><code>project(kreversi)
  
  set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
  
  if(NOT COMPILING_KDEGAMES)
      find_package(KDE4 REQUIRED)
      include(KDE4Defaults)
      include(MacroLibrary)
      find_package(KDEGames 4.9.0 REQUIRED)
  
      add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
      add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
      include_directories(${KDEGAMES_INCLUDE_DIRS} ${KDEGAMES_INCLUDE_DIR}/highscore ${KDE4_INCLUDES} ${QDBUS_INCLUDE_DIRS})
  endif(NOT COMPILING_KDEGAMES)
  
  add_subdirectory( pics ) 
  add_subdirectory( sounds ) 
  add_subdirectory( icons ) 
  add_subdirectory( doc )
  
  find_package(Lua52 REQUIRED) #### I ADDED THIS LINE #####
  
  include_directories( ${CMAKE_SOURCE_DIR}/libkdegames/highscore ${LUA_INCLUDE_DIR} ) #### I MODIFIED THIS LINE #####
  
  ########### next target ###############
  
  set(kreversi_SRCS 
      kreversichip.cpp
      kreversigame.cpp
      kreversiscene.cpp
      kreversiview.cpp
      Engine.cpp
      highscores.cpp
      mainwindow.cpp
      main.cpp )
  
  kde4_add_kcfg_files(kreversi_SRCS preferences.kcfgc)
  
  kde4_add_app_icon(kreversi_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/icons/hi*-app-kreversi.png")
  kde4_add_executable(kreversi ${kreversi_SRCS})
  target_link_libraries(kreversi ${KDE4_KDEUI_LIBS} kdegames ${LUA_LIBRARIES}) #### I MODIFIED THIS LINE #####
  install(TARGETS kreversi  ${INSTALL_TARGETS_DEFAULT_ARGS} )
  
  ########### install files ###############
  
  install( PROGRAMS kreversi.desktop  DESTINATION  ${XDG_APPS_INSTALL_DIR} )
  #install( FILES kreversi.kcfg  DESTINATION  ${KCFG_INSTALL_DIR} )
  install( FILES kreversiui.rc  DESTINATION  ${DATA_INSTALL_DIR}/kreversi )
  </code></pre>
  
  <p>When i try to run cmake, and then make, there are compile errors "undefined reference to <code>luaL_newstate()'" and "undefined reference to</code>luaL_openlibs(lua_State*)'" which may indicate something wrong with the linking process. </p>
  
  <p>i tried : </p>
  
  <pre><code>message("lua library : " ${LUA_LIBRARIES})
  </code></pre>
  
  <p>and it outputs this : </p>
  
  <pre><code>lua library : /usr/lib/i386-linux-gnu/liblua5.2.so/usr/lib/i386-linux-gnu/libm.so
  </code></pre>
  
  <p>is that correct? how can i include and link lua5.2 in cmake?</p>
  
  <p>I have already installed lua5.2-dev in my computer and without cmake, have successfully compile c-lua program with gcc test.c -I/usr/include/lua5.2 -llua5.2</p>