miniupnp.tuxfamily.org Forum Index miniupnp.tuxfamily.org
The forum about miniupnp and libnatpmp
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Help] Compiling and Linking with Cmake

 
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpc Compilation/Installation
View previous topic :: View next topic  
Author Message
Tech



Joined: 27 Feb 2013
Posts: 1

PostPosted: Sun Mar 03, 2013 2:51 pm    Post subject: [Help] Compiling and Linking with Cmake Reply with quote

Hi, I'm working on a open source project and I'm using miniupnp libraries to do do port forwarding. I added the function upnp(string port), on the file tools.cpp, also the proper #include <miniupnpc/miniupnp.h> #include <miniupnpc/upnpcommands.h>. But i'm having problem when the program is linked
Here's the CMakeLists.txt
Code:
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(otserv CXX)

# CMake 2.6 compatibility
IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6)
   GET_FILENAME_COMPONENT(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6)

SET(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps")

# Additional CMake modules
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")

# Choose default build type if not specified
IF(NOT CMAKE_BUILD_TYPE)
   SET(CMAKE_BUILD_TYPE RelWithDebInfo)
ENDIF(NOT CMAKE_BUILD_TYPE)
MESSAGE(STATUS "BUILD TYPE: " ${CMAKE_BUILD_TYPE})

SET(SERVER_SOURCES "")
SET(SERVER_HEADERS "")
SET(SERVER_LIBRARIES "")
SET(SERVER_DEFINITIONS "")
SET(SERVER_INCLUDE_DIRS "")
SET(SERVER_LIBRARY_DIRS "")

SET(VERSION "0.7.0")
SET(VERSION_MAJOR 0)
SET(VERSION_MINOR 7)
SET(VERSION_MICRO 0)

# Select the database drivers
OPTION(USE_SQLITE "build the server with SQLite database support" ON)
OPTION(USE_MYSQL "build the server with MySQL database support" OFF)
OPTION(USE_ODBC "build the server with ODBC database support" OFF)
OPTION(USE_POSTGRE "build the server with PostgreSQL database support" OFF)
OPTION(USE_LUAJIT "build the server with lua jit" OFF)
OPTION(USE_CPP11 "build with the new C++11 standard enabled" OFF)
OPTION(SKULLSYSTEM "enable skull system" OFF)
OPTION(OTALLOCATOR "enable otserv custom allocator" OFF)
OPTION(DEBUGGING "enable debugging of internal systems" OFF)
OPTION(USE_PCH "enable usage of precompiled headers" OFF)
OPTION(USE_STATIC_LIBS "use static libraries for linking" OFF)

# Compiler flags for gcc, mingw32 and clang
IF(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
   SET(CMAKE_CXX_FLAGS                "-Wall")
   SET(CMAKE_CXX_FLAGS_DEBUG          "-O0 -g")
   SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -g")
   SET(CMAKE_CXX_FLAGS_RELEASE        "-O2")
   SET(CMAKE_CXX_FLAGS_MINSIZEREL     "-Os")
   IF(USE_STATIC_LIBS AND NOT APPLE)
      SET(CMAKE_CXX_LINK_FLAGS "-static-libgcc -static-libstdc++")
   ENDIF()
   IF(USE_CPP11)
      IF(WIN32)
         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
      ELSE()
         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
      ENDIF()
   ENDIF()
   IF(WIN32)
      SET(SERVER_LIBRARIES ${SERVER_LIBRARIES} ws2_32 mswsock)
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthreads")
   ELSEIF(APPLE)
      SET(SERVER_DEFINITIONS ${SERVER_DEFINITIONS} -D_REENTRANT)
   ELSE(APPLE)
      SET(SERVER_LIBRARIES ${SERVER_LIBRARIES} dl)
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
   ENDIF()
# Compiler flags for MSVC
ELSEIF(MSVC)
   SET(SERVER_DEFINITIONS ${SERVER_DEFINITIONS}
      -D_CRT_SECURE_NO_WARNINGS
      -D_CRT_SECURE_NO_DEPRECATE
      -D_CRT_NON_CONFORMING_SWPRINTFS
      -D_SCL_SECURE_NO_DEPRECATE
      -DWIN32_LEAN_AND_MEAN
      -DNOMINMAX)

   # Disable iterator checking on release builds
   IF(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
      SET(SERVER_DEFINITIONS ${SERVER_DEFINITIONS}
         -D_SECURE_SCL=0
         -D_SECURE_SCL_THROWS=0
         -D_HAS_ITERATOR_DEBUGGING=0)
   ENDIF()

   SET(SERVER_LIBRARY_DIRS ${SERVER_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS})
ENDIF()

# Boost
SET(Boost_USE_MULTITHREADED ON)
IF(USE_STATIC_LIBS)
   SET(Boost_USE_STATIC_LIBS ON)
ENDIF()
IF(MINGW)
   SET(Boost_THREADAPI win32)
   SET(SERVER_DEFINITIONS ${SERVER_DEFINITIONS} -DBOOST_THREAD_USE_LIB)
ENDIF()
FIND_PACKAGE(Boost COMPONENTS thread regex system filesystem REQUIRED)
SET(SERVER_LIBRARIES ${SERVER_LIBRARIES} ${Boost_LIBRARIES})
SET(SERVER_INCLUDE_DIRS ${SERVER_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})

# LibXML2
FIND_PACKAGE(LibXml2 REQUIRED)
SET(SERVER_LIBRARIES ${SERVER_LIBRARIES} ${LIBXML2_LIBRARIES})
SET(SERVER_INCLUDE_DIRS ${SERVER_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR})

# GMP
FIND_PACKAGE(GMP REQUIRED)
SET(SERVER_LIBRARIES ${SERVER_LIBRARIES} ${GMP_LIBRARY})
SET(SERVER_INCLUDE_DIRS ${SERVER_INCLUDE_DIRS} ${GMP_INCLUDE_DIR})

# Lua
IF(USE_LUAJIT)
   FIND_PACKAGE(LuaJIT REQUIRED)
   SET(SERVER_INCLUDE_DIRS ${SERVER_INCLUDE_DIRS} ${LUAJIT_INCLUDE_DIR})
   SET(SERVER_LIBRARIES ${SERVER_LIBRARIES} ${LUAJIT_LIBRARY})
   MESSAGE(STATUS "LuaJIT: ON")
ELSE()
   FIND_PACKAGE(Lua51 REQUIRED)
   SET(SERVER_INCLUDE_DIRS ${SERVER_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})
   SET(SERVER_LIBRARIES ${SERVER_LIBRARIES} ${LUA_LIBRARY})
   MESSAGE(STATUS "LuaJIT: OFF")
ENDIF()

# SQLite, enabled by default
IF(USE_SQLITE)
   FIND_PACKAGE(SQLite REQUIRED)
   SET(SERVER_SOURCES ${SERVER_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/src/database_driver_sqlite.cpp)
   SET(SERVER_HEADERS ${SERVER_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/src/database_driver_sqlite.h)
   SET(SERVER_DEFINITIONS ${SERVER_DEFINITIONS} -D__USE_SQLITE__)
   SET(SERVER_LIBRARIES ${SERVER_LIBRARIES} ${SQLITE_LIBRARY})
   SET(SERVER_INCLUDE_DIRS ${SERVER_INCLUDE_DIRS} ${SQLITE_INCLUDE_DIR})
   MESSAGE(STATUS "SQLite: ON")
ENDIF()

# MySQL
IF(USE_MYSQL)
   FIND_PACKAGE(MySQL REQUIRED)
   SET(SERVER_SOURCES ${SERVER_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/src/database_driver_mysql.cpp)
   SET(SERVER_HEADERS ${SERVER_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/src/database_driver_mysql.h)
   SET(SERVER_DEFINITIONS ${SERVER_DEFINITIONS} -D__USE_MYSQL__)
   SET(SERVER_LIBRARIES ${SERVER_LIBRARIES} ${MYSQL_LIBRARY})
   SET(SERVER_INCLUDE_DIRS ${SERVER_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIR})
   MESSAGE(STATUS "MySQL: ON")
ENDIF()

# PostgreSQL
IF(USE_POSTGRE)
   FIND_PACKAGE(PostgreSQL REQUIRED)
   SET(SERVER_SOURCES ${SERVER_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/src/database_driver_pgsql.cpp)
   SET(SERVER_HEADERS ${SERVER_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/src/database_driver_pgsql.h)
   SET(SERVER_DEFINITIONS ${SERVER_DEFINITIONS} -D__USE_PGSQL__)
   SET(SERVER_LIBRARIES ${SERVER_LIBRARIES} ${POSTGRESQL_LIBRARY})
   SET(SERVER_INCLUDE_DIRS ${SERVER_INCLUDE_DIRS} ${POSTGRESQL_INCLUDE_DIR})
   MESSAGE(STATUS "PostgreSQL: ON")
ENDIF()
# ODBC
IF(USE_ODBC)
   SET(SERVER_SOURCES ${SERVER_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/src/database_driver_odbc.cpp)
   SET(SERVER_HEADERS ${SERVER_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/src/database_driver_odbc.h)
   SET(SERVER_DEFINITIONS ${SERVER_DEFINITIONS} -D__USE_ODBC__)
   SET(SERVER_LIBRARIES ${SERVER_LIBRARIES} ${ODBC_LIBRARY})
   SET(SERVER_INCLUDE_DIRS ${SERVER_INCLUDE_DIRS} ${ODBC_INCLUDE_DIR})
   MESSAGE(STATUS "ODBC: ON")
ENDIF()

IF(WIN32)
   SET(SERVER_DEFINITIONS ${SERVER_DEFINITIONS}
      -D__WINDOWS__
      -DBOOST_ASIO_ENABLE_CANCELIO)
ELSE()
   SET(SERVER_DEFINITIONS ${SERVER_DEFINITIONS} -D_THREAD_SAFE)
ENDIF()

IF(DEBUGGING)
   SET(SERVER_DEFINITIONS ${SERVER_DEFINITIONS} -D__DEBUG__MOVESYS__ -D__DEBUG_HOUSES__ -D__DEBUG_MAILBOX__ -D__DEBUG_LUASCRIPTS__ -D__DEBUG_NET__)
   MESSAGE(STATUS "Debugging: ON")
ENDIF()

IF(SKULLSYSTEM)
   SET(SERVER_DEFINITIONS ${SERVER_DEFINITIONS} -D__SKULLSYSTEM__)
   MESSAGE(STATUS "Skull System: ON")
ELSE()
   MESSAGE(STATUS "Skull System: OFF")
ENDIF()

IF(OTALLOCATOR)
   SET(SERVER_DEFINITIONS ${SERVER_DEFINITIONS} -D__OTSERV_ALLOCATOR__)
   MESSAGE(STATUS "Custom Allocator: ON")
ENDIF()

# Sources
SET(SERVER_SOURCES ${SERVER_SOURCES}
   ${CMAKE_CURRENT_SOURCE_DIR}/src/actor.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/admin.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/allocator.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/ban.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/beds.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/chat.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/combat.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/condition.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/condition_attributes.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/configmanager.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/connection.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/const.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/container.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/creature.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/creature_manager.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/creature_type.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/cylinder.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/database_driver.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/depot.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/enums.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/exception.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/fileloader.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/game.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/house.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/housetile.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/http_request.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/ioaccount.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/iomapotbm.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/iomapserialize.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/ioplayer.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/item.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/item_attributes.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/items.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/logger.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/lua_manager.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/map.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/md5.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/networkmessage.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/otserv.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/outputmessage.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/party.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/player.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/position.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/protocol.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/protocolgame.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/protocollogin.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/protocolold.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/rsa.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/scheduler.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/script_environment.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/script_event.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/script_functions.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/script_listener.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/script_manager.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/server.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/sha1.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/spawn.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/status.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/tasks.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/teleport.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/thing.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/tile.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/tools.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/town.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/trashholder.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/vocation.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/src/waitlist.cpp
)

# Headers
SET(SERVER_HEADERS ${SERVER_HEADERS}
   ${CMAKE_CURRENT_SOURCE_DIR}/src/account.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/actor.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/admin.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/allocator.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/ban.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/beds.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/boost_common.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/chat.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/classes.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/combat.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/condition.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/condition_attributes.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/configmanager.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/connection.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/const.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/container.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/creature.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/creature_manager.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/creature_type.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/cylinder.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/database_driver.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/definitions.h # We need to get rid of this
   ${CMAKE_CURRENT_SOURCE_DIR}/src/depot.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/enum.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/enums.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/exception.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/fileloader.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/game.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/house.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/housetile.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/http_request.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/ioaccount.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/iomap.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/iomapotbm.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/iomapserialize.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/ioplayer.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/item.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/item_attributes.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/itemloader.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/items.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/logger.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/lua_manager.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/map.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/md5.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/networkmessage.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/otsystem.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/outfit.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/outputmessage.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/party.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/player.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/position.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/protocol.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/protocolconst.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/protocolgame.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/protocollogin.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/protocolold.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/rsa.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/scheduler.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/script_environment.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/script_event.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/script_listener.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/script_manager.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/server.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/sha1.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/shared_ptr.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/singleton.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/spawn.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/status.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/tasks.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/teleport.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/templates.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/thing.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/tile.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/tools.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/town.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/trashholder.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/vocation.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/waitlist.h
   ${CMAKE_CURRENT_SOURCE_DIR}/src/waypoints.h
)

INCLUDE_DIRECTORIES(${SERVER_INCLUDE_DIRS})
LINK_DIRECTORIES(${SERVER_LIBRARY_DIRS})
ADD_DEFINITIONS(${SERVER_DEFINITIONS})
ADD_EXECUTABLE(${PROJECT_NAME} ${SERVER_SOURCES} ${SERVER_HEADERS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${SERVER_LIBRARIES})

IF(USE_PCH)
   INCLUDE(cotire)
   cotire(${PROJECT_NAME})
   MESSAGE(STATUS "Use precompiled header: ON")
ELSE()
   MESSAGE(STATUS "Use precompiled header: OFF")
ENDIF()

ENABLE_TESTING()
ADD_TEST(help_test otserv --help )
ADD_TEST(version_test otserv --version )
SET_TESTS_PROPERTIES(version_test PROPERTIES PASS_REGULAR_EXPRESSION "^OTServ ${VERSION}")
ADD_TEST(badoption_test otserv --somenonexistentoption )
SET_TESTS_PROPERTIES(badoption_test PROPERTIES WILL_FAIL true)


And the output...

Linking CXX executable otserv
CMakeFiles/otserv.dir/src/tools.cpp.o: In function `upnp(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/home/victor/server/src/tools.cpp:51: undefined reference to `upnpDiscover'
/home/victor/server/src/tools.cpp:62: undefined reference to `UPNP_GetValidIGD'
/home/victor/server/src/tools.cpp:67: undefined reference to `UPNP_AddPortMapping'
/home/victor/server/src/tools.cpp:71: undefined reference to `freeUPNPDevlist'
collect2: ld returned 1 exit status
make[2]: *** [otserv] Error 1
make[1]: *** [CMakeFiles/otserv.dir/all] Error 2
make: *** [all] Error 2

I hope anyone can help Smile. I don't know where to add the -lminiupnpc thing.
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1429

PostPosted: Mon Mar 04, 2013 10:37 am    Post subject: Reply with quote

I don't know CMake, but I guess that miniupnpc library should be added to SERVER_LIBRARIES or directly to the TARGET_LINK_LIBRARIES command
Code:
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${SERVER_LIBRARIES})

_________________
Main miniUPnP author.
http://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpc Compilation/Installation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP
© 2007 Thomas Bernard, author of MiniUPNP.