0

I have compiled program with cmake.The cmakelist.txt:

cmake_minimum_required (VERSION 2.6) project (clustering) IF(CMAKE_SIZEOF_VOID_P EQUAL 4) SET(LIB_SUFFIX "") ELSE(CMAKE_SIZEOF_VOID_P EQUAL 4) SET(LIB_SUFFIX 64) ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4) SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}") find_package(Eigen2 REQUIRED) include_directories(${Eigen2_INCLUDE_DIR}) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) endif(NOT CMAKE_BUILD_TYPE) if(CMAKE_BUILD_TYPE MATCHES "Debug") set(LIB_NAME clusteringd) else(CMAKE_BUILD_TYPE MATCHES "Debug") set(LIB_NAME clustering) endif(CMAKE_BUILD_TYPE MATCHES "Debug") file(GLOB LIB_PUBLIC_HEADERS "${CMAKE_SOURCE_DIR}/*.h") file(GLOB LIB_SOURCES "${CMAKE_SOURCE_DIR}/*.cpp") #add_library (${LIB_NAME}-s STATIC ${LIB_PUBLIC_HEADERS} ${LIB_SOURCES}) add_library (${LIB_NAME} SHARED ${LIB_PUBLIC_HEADERS} ${LIB_SOURCES}) install( TARGETS ${LIB_NAME} LIBRARY DESTINATION lib${LIB_SUFFIX} ) #install( # TARGETS ${LIB_NAME}-s # ARCHIVE DESTINATION lib${LIB_SUFFIX} #) install( FILES ${LIB_PUBLIC_HEADERS} DESTINATION include/${LIB_NAME} ) 

The problem is that in my folder /clusteringmaster/build/CMakeFiles/2.8.12.2/ I have two folders CompilerIdC and CompilerIdCXX,both of them have exe file.As Sergey pointed out exe should be located in bin directory.When I list my CmakeFile

2.8.12.2 cmake.check_cache CMakeOutput.log Makefile2 progress.marks clustering.dir CMakeDirectoryInformation.cmake CMakeTmp Makefile.cmake TargetDirectories.txt 

From the authors tutorial

Build

You will need the Eigen2 library (libeigen2-devel) and CMake (only tested under Linux). $ mkdir release $ cd release $ cmake ../ $ make 

Should I write cmake -- build /home/milenko/clusteing-master/release?

I have not worked with cmake before,how should I solve this confusion?

7
  • So what is the problem? Is any error message or what? Commented Jul 21, 2015 at 11:05
  • According to cmake file you should search for result in /clusteringmaster/build/bin/ (SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)) Commented Jul 21, 2015 at 11:08
  • @Sergey I don'think it is an error,just I do not have any bin folder.I will further edit my question. Commented Jul 21, 2015 at 11:11
  • Then just re-read documentation about what cmake is. It is build project generator - so you forget to build your project after you've generated it. Do it with 'cmake --build .' Commented Jul 21, 2015 at 11:14
  • There is no confusion. 'cmake --build <path>' will call native build tool for which you've generated. In your case it will be 'make'. Commented Jul 21, 2015 at 12:15

1 Answer 1

4

One item is that should use the cmake variable ${PROJECT_NAME} as the target name for the add_library command. (Your project name is specified as "clustering" because of the project (clustering) statement.) To get a d suffix for the debug configuration build, use set(CMAKE_DEBUG_POSTFIX d). I also like to set the output directory variables using

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") 

(I will even set the _DEBUG and _RELEASE variants, but this may cause problems when you are first getting started, so I would wait before doing that.)

Sign up to request clarification or add additional context in comments.

1 Comment

I apologize. I was wrong--you do have a project command at the top of your CMakeLists.txt--I must have missed it when it scrolled out of the frame. Your project command is project (clustering). I will edit my answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.