[CMake] Problems finding dependence library

2012-09-20 Thread Reza Housseini
Hello list

I have a problem finding a dependent library of my own libsieve.so:

set(CPPLIB_DIR "${CMAKE_SOURCE_DIR}/../core/build")
find_library(CPPLIB_SIEVE_LIBRARY NAMES libsieve PATHS CPPLIB_DIR)

I have the following folder structure:

core
  build
libsieve.so
project
  CMakeLists.txt

It fails to find the file, what am I doing wrong? I also tried to
write my own FindLibSieve.cmake:

include(LibFindMacros)

# Use pkg-config to get hints about paths
libfind_pkg_check_modules(LIBSIEVE_PKGCONF libsieve.so)

# Include dir
find_path(LIBSIEVE_INCLUDE_DIR
  NAMES Sieve.h
  PATHS ${LIBSIEVE_PKGCONF_INCLUDE_DIRS}
)

# Finally the library itself
find_library(LIBSIEVE_LIBRARY
  NAMES libsieve Sieve libsieve.dll.a
  PATHS ${LIBSIEVE_PKGCONF_LIBRARY_DIRS}
)

# Set the include dir variables and the libraries and let
libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this
this lib depends on.
set(LIBSIEVE_PROCESS_INCLUDES LIBSIEVE_INCLUDE_DIR)
set(LIBSIEVE_PROCESS_LIBS LIBSIEVE_LIBRARY)
libfind_process(LIBSIEVE)

Als no success.
Thanks for any input!
Reza
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Problems finding dependence library

2012-09-20 Thread Reza Housseini
On Thu, Sep 20, 2012 at 5:32 PM, Bogdan Cristea  wrote:
> On Thursday 20 September 2012 17:25:35 Reza Housseini wrote:
>> set(CPPLIB_DIR "${CMAKE_SOURCE_DIR}/../core/build")
>> find_library(CPPLIB_SIEVE_LIBRARY NAMES libsieve PATHS CPPLIB_DIR)
>
> Use instead sieve for your library name. Also, check with
> message(${CPPLIB_DIR})
> the path to your library
>
> --
> Bogdan
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

Thank you for your answer. I tried that but it didn't work. Paths are
alright. I even used absolute paths. What could be the problem of
that?
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Problems finding dependence library

2012-09-21 Thread Reza Housseini
On Fri, Sep 21, 2012 at 1:55 PM, Bogdan Cristea  wrote:
> On Friday 21 September 2012 07:48:27 you wrote:
>> Thank you for your answer. I tried that but it didn't work. Paths are
>> alright. I even used absolute paths. What could be the problem of
>> that?
>
> Have a look at CMakeError.log
>
> --
> Bogdan

Hello Bogdan

The problem was that I had to wrap my path variable in curly braces:

find_library(CPPLIB_SIEVE_LIBRARY NAMES sieve PATHS ${CPPLIB_DIR})

Thank you for your help!
Cheers Reza
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Custom command with included header file

2012-09-21 Thread Reza Housseini
Hello
I want to add my own library libsieve.so with the header file Sieve.h
to the custom target. I have the following setup:

find_program(MKOCTFILE_EXECUTABLE mkoctfile)
if(NOT MKOCTFILE_EXECUTABLE)
  message(SEND_ERROR "Failed to find mkoctfile, is it in your $PATH?")
endif()

set(OCT_FILE "multidecksieve.oct")
set(OCT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/multidecksieve.cpp")
set(CPPLIB_DIR "${CMAKE_SOURCE_DIR}/../core/build")
set(CPPLIB_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/../core")

find_library(CPPLIB_SIEVE_LIBRARY NAMES sieve PATHS ${CPPLIB_DIR})
find_path(CPPLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/../core)

if ("${CPPLIB_SIEVE_LIBRARY}" STREQUAL "CPPLIB_SIEVE_LIBRARY-NOTFOUND")
  message(FATAL_ERROR "One of the libraries wasn't found!")
endif ()

include_directories(CPPLIB_INCLUDE_DIR)

add_custom_command(
  OUTPUT ${OCT_FILE}
  COMMAND ${MKOCTFILE_EXECUTABLE} "${OCT_SRC}"
  DEPENDS ${CPPLIB_INCLUDE_DIR}/Sieve.h ${CPPLIB_SIEVE_LIBRARY}
  COMMENT "Generating ${OCT_FILE}"
  VERBATIM)

add_custom_target(multidecksieve ALL
  DEPENDS ${OCT_FILE})

But it gives me the error that it can't find the Sieve.h file:
fatal error: Sieve.h: No such file or directory

What is the correct way to do it?

Thanks and best wishes
Reza
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Custom command with included header file

2012-09-24 Thread Reza Housseini
On Fri, Sep 21, 2012 at 2:26 PM, Reza Housseini  wrote:
> Hello
> I want to add my own library libsieve.so with the header file Sieve.h
> to the custom target. I have the following setup:
>
> find_program(MKOCTFILE_EXECUTABLE mkoctfile)
> if(NOT MKOCTFILE_EXECUTABLE)
>   message(SEND_ERROR "Failed to find mkoctfile, is it in your $PATH?")
> endif()
>
> set(OCT_FILE "multidecksieve.oct")
> set(OCT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/multidecksieve.cpp")
> set(CPPLIB_DIR "${CMAKE_SOURCE_DIR}/../core/build")
> set(CPPLIB_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/../core")
>
> find_library(CPPLIB_SIEVE_LIBRARY NAMES sieve PATHS ${CPPLIB_DIR})
> find_path(CPPLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/../core)
>
> if ("${CPPLIB_SIEVE_LIBRARY}" STREQUAL "CPPLIB_SIEVE_LIBRARY-NOTFOUND")
>   message(FATAL_ERROR "One of the libraries wasn't found!")
> endif ()
>
> include_directories(CPPLIB_INCLUDE_DIR)
>
> add_custom_command(
>   OUTPUT ${OCT_FILE}
>   COMMAND ${MKOCTFILE_EXECUTABLE} "${OCT_SRC}"
>   DEPENDS ${CPPLIB_INCLUDE_DIR}/Sieve.h ${CPPLIB_SIEVE_LIBRARY}
>   COMMENT "Generating ${OCT_FILE}"
>   VERBATIM)
>
> add_custom_target(multidecksieve ALL
>   DEPENDS ${OCT_FILE})
>
> But it gives me the error that it can't find the Sieve.h file:
> fatal error: Sieve.h: No such file or directory
>
> What is the correct way to do it?
>
> Thanks and best wishes
> Reza

I was able to make it to work:

find_program(MKOCTFILE_EXECUTABLE mkoctfile)
if(NOT MKOCTFILE_EXECUTABLE)
  message(SEND_ERROR "Failed to find mkoctfile, is it in your $PATH?")
endif()

## Compile the octfile
set(OCT_CXXFLAGS "-O2 -Wall -Wextra -std=c++0x")
set(ENV{CXXFLAGS} ${OCT_CXXFLAGS})
set(OCT_FILE "${PROJECT_BINARY_DIR}/multidecksieve.oct")
set(OCT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/multidecksieve.cpp)
set(CPPLIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../core/build)
set(CPPLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../core")

find_library(CPPLIB_SIEVE_LIBRARY NAMES sieve PATHS ${CPPLIB_DIR})

if ("${CPPLIB_SIEVE_LIBRARY}" STREQUAL "CPPLIB_SIEVE_LIBRARY-NOTFOUND")
  message(FATAL_ERROR "One of the libraries wasn't found!")
endif ()

set(CPPLIB_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../core/build")
set(CPPLIB_HINT_INCLUDE_DIR ${CPPLIB_DIR})

set(DEPENDENCIES ${OCT_SRC} ${CPPLIB_SIEVE_LIBRARY})
add_custom_command(
  OUTPUT ${OCT_FILE}
  DEPENDS ${DEPENDENCIES}
  COMMAND ${MKOCTFILE_EXECUTABLE}
  ARGS ${OCT_SRC}
  ARGS -I${CPPLIB_INCLUDE_DIR} -L${CPPLIB_DIR} -lsieve
  COMMENT "Generating ${OCT_FILE}"
  VERBATIM)

add_custom_target(multidecksieve ALL
  DEPENDS ${OCT_FILE})

It compiles fine, but when I run the created file (in GNU Octave) I
get an error message saying the library libsieve.so is not found
although it exists on the provided path. What is the problem here?

Thanks for any answer
Reza
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Linking library with custom target

2012-12-13 Thread Reza Housseini
Hello

I want to link a library to a custom target:

add_custom_command(
  OUTPUT ${FILE}
  DEPENDS ${SRC}
  COMMAND ${EXECUTABLE}
  ARGS ${SRC}
  COMMENT "Generating ${FILE}"
  VERBATIM)

add_custom_target(mytarget ALL
  DEPENDS ${FILE})

target_link_libraries(mytarget /usr/local/lib/libmylib.so)

But it don't seems to work instead I have to use:

add_custom_command(
  OUTPUT ${FILE}
  DEPENDS ${SRC}
  COMMAND ${EXECUTABLE}
  ARGS ${SRC}
  ARGS -I${CPPLIB_INCLUDE_DIR} -L${CPPLIB_DIR} -lmylib
  COMMENT "Generating ${FILE}"
  VERBATIM)

add_custom_target(mytarget ALL
  DEPENDS ${FILE})

Why is this so? Can't I use target_link_library with add_custom_target?

Thnaks for clarification!

Cheers Reza
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] How to import platform-independent library with add_library()?

2012-12-14 Thread Reza Housseini
Hello Guys

I try to import a library and was now wondering if there's a
platform-independent way?
Here's my code:

  add_library(mylib SHARED IMPORTED)
  set_target_properties(mylib PROPERTIES
IMPORTED_LOCATION ${CPPLIB_DIR}/libmylib.so)

But now what about using this CMakeLists.txt file under Windows? Can't
I just specifie a path? When I do so I get the following error message
from the linker:

  /usr/bin/ld: cannot find ../../core/build: File format not recognized

So he is just linking the path instead of the library.

Thanks for your help!
Cheers Reza
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] How to import platform-independent library with add_library()?

2012-12-14 Thread Reza Housseini
On Fri, Dec 14, 2012 at 11:47 AM, Andreas Pakulat  wrote:
> Hi,
>
> On Fri, Dec 14, 2012 at 11:16 AM, Reza Housseini  
> wrote:
>> Hello Guys
>>
>> I try to import a library and was now wondering if there's a
>> platform-independent way?
>
> Not in the sense that CMake would handle this for you magically. At
> least not when importing libraries that are not shipping with a
> corresponding cmake file that sets this stuff up.
>
> Andreas

I found the solution, I had to use the find_library command and
specify the PATHS variable.

  find_library(MYLIB mylib
PATHS ${CPPLIB_DIR}
  )

Thank you anyway!
Regards
Reza
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Components not recognized with FindHDF5.cmake

2013-10-20 Thread Reza Housseini
Hello

I try to find the hdf5 libraries, but it seems that the components are not
recognized. I use

FIND_PACKAGE(HDF5 COMPONENTS C CXX HL REQUIRED)

but it only comes up with the libhdf5.so and doesn't detect libhdf5_cpp.so
and libhdf5_hl.so. I also cleaned the whole build directory but without
success.

It seems that it doesn't even look for the libraries because in the find
script the execution already skips the components at the beginning

IF (NOT HDF%_FIND_COMPONENTS)
  SET(HDF5_LANGUAGE_BINDINGS "C")
ELSE ()
  # This part is not executed
  
ENDIF()

Thanks for any hints

Cheers Reza
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake