Hello,
I have so far been using make to link to the CPLEX library. This library does not offer any cmake support but they provide the following guidance to link to their library:
Setting up CPLEX on GNU/Linux/macOS - IBM Documentation
Based on this, for several years, I have been able to link to their library via the following commands in the makefile which I used to invoke via make.
# Link Libraries and Options
LDLIBSOPTIONS=-L /opt/ibm/ILOG/CPLEX_Studio1210/cplex/lib/x86-64_linux/static_pic
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/linux: ${OBJECTFILES}
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/linux ${OBJECTFILES} ${LDLIBSOPTIONS} -lcplex -lm -lpthread -ldl -lppl -lgmp -lgmpxx
${OBJECTDIR}/_ext/ce8a225a/userfile.o: ../../../userfile.cpp
${MKDIR} -p ${OBJECTDIR}/_ext/ce8a225a
${RM} "$@.d"
$(COMPILE.cc) -O2 -DIL_STD -DNDEBUG -I/opt/ibm/ILOG/CPLEX_Studio1210/cplex/include -I../include -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/_ext/ce8a225a/userfile.o ../../../userfile.cpp
The above commands are easy enough for me to understand what is going on and what is expected of the compiler/linker.
I am trying to achieve the same using CMake. There are places where I have found FindCPLEX.cmake (for e.g., https://github.com/ampl/mp/blob/master/support/cmake/FindCPLEX.cmake) using which I have been able to compile and link my old CPLEX projects without using make, but now using CMake.
Now, I am trying to gain an understanding of how the old make commands have been mapped over to CMake, but I am struggling. For instance, -lcplex -lm -lpthread of the old direct make compiling and linking, which part of FindCPLEX.cmake file achieves the equivalent? Also, with -DIL_STD, where is that set in FindCPLEX.cmake?
For instance, does line 99 here (of the FindCPLEX.cmake file referred to above):
find_package(Threads)
perform the equivalent of -lpthread? Also, are the lines following line 154
check_library_exists(m floor "" HAVE_LIBM)
if (HAVE_LIBM)
set(CPLEX_LINK_LIBRARIES ${CPLEX_LINK_LIBRARIES} m)
endif ()
the equivalent of -lm in the make command ?
Thank you for your help.