[CMake] set file path issue

Sajjadul Islam sajjadul.islam.bd at gmail.com
Mon Aug 26 00:41:57 EDT 2013


Hi forum,

I am quite new to CMake tool. The application execution file that i am
generating using CMake is stored in a separate directory and the execution
reads an external file and store another external file inside the source
root. I set the path for it.

But it seems that it is not getting the external files. For example inside
the source i have main.cpp , the external input file to read - main.cl.
When i compile the source the generated execution file is stored in another
directory called bin. I go inside bin and run the execution and then it
says that "No file found to read from as main.cl". Then if i put the input
file inside bin it works fine.
I do not want to have it this way. I want CMake direct the application to
look for input files from the source directory and save file as well inside
the source directory.

I am attaching my current CMakeLists.txt for your kind review and looking
forward to some hint to get around this issue.


Regards
Sajjad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130826/ee84c368/attachment.htm>
-------------- next part --------------
#########################################################################
# Set target name und set path to data folder of the target
#########################################################################

SET(TARGETNAME osgOpenCLEndiannessDemo)
SET(TARGET_DATA_PATH "${DATA_PATH}/${TARGETNAME}")


#########################################################################
# Do necessary checking stuff (check for other libraries to link against ...)
#########################################################################

# find osg
INCLUDE(Findosg)
INCLUDE(FindosgUtil)
INCLUDE(FindOpenThreads)
INCLUDE(FindosgViewer)
INCLUDE(FindosgGA)
INCLUDE(FindosgDB)
# check for OpenCL
INCLUDE(FindOpenCL) 


#Uncomment to enable CUDA Debugging via Parallel NSight
#SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -G)
 



#########################################################################
# Set basic include directories
#########################################################################

# set include dirs
SET(HEADER_PATH ${osgCompute_SOURCE_DIR}/examples/${TARGETNAME}/include)
INCLUDE_DIRECTORIES(
    ${HEADER_PATH}
    ${OSG_INCLUDE_DIR}
    ${CUDA_TOOLKIT_INCLUDE}
)


#########################################################################
# Collect header and source files and process macros
#########################################################################

# collect all headers

SET(TARGET_H
)


SET(MY_OPENCL_SOURCE_FILES
	main.cl
)

# Use the CUDA_COMPILE macro.
#OPENCL_COMPILE( OPENCL_FILES ${MY_OPENCL_SOURCE_FILES} )

# collect the sources
SET(TARGET_SRC
	main.cpp
    ${MY_OPENCL_SOURCE_FILES} 
)

#########################################################################
# Setup groups for resources (mainly for MSVC project folders)
#########################################################################

# Setup groups for headers (especially for files with no extension)
SOURCE_GROUP(
    "Header Files"
    FILES ${TARGET_H}     
)

# Setup groups for sources 
SOURCE_GROUP(
    "Source Files"
    FILES ${TARGET_SRC}
)

# Setup groups for resources 

# First: collect the necessary files which were not collected up to now
# Therefore, fill the following variables: 
# MY_ICE_FILES - MY_MODEL_FILES - MY_SHADER_FILES - MY_UI_FILES - MY_XML_FILES

# collect shader files
SET(MY_SHADER_FILES
)

# finally, use module to build groups
INCLUDE(GroupInstall)


# now set up the ADDITIONAL_FILES variable to ensure that the files will be visible in the project
# and/or that they are forwarded to the linking stage
SET(ADDITIONAL_FILES
	#${MY_SHADER_FILES}
	#${OPENCL_FILES}
	${MY_OPENCL_SOURCE_FILES} 
)


#########################################################################
# Setup libraries to link against
#########################################################################

# put here own project libraries, for example. (Attention: you do not have
# to differentiate between debug and optimized: this is done automatically by cmake
SET(TARGET_ADDITIONAL_LIBRARIES
	osgCompute
	osgOpenCL
	#osgOpenCLStats
)


# put here the libraries which are collected in a variable (i.e. most of the FindXXX scrips)
# the macro (LINK_WITH_VARIABLES) ensures that also the ${varname}_DEBUG names will resolved correctly
SET(TARGET_VARS_LIBRARIES 	
	OPENTHREADS_LIBRARY
	OSG_LIBRARY
	OSGUTIL_LIBRARY
	#added by sajjad - the opencl library to link with
	OPENCL_LIBRARIES
)
	

#########################################################################
# Example setup and install
#########################################################################

# this is a user definded macro which does all the work for us
# it also takes into account the variables TARGET_SRC,
# TARGET_H and TARGET_ADDITIONAL_LIBRARIES and TARGET_VARS_LIBRARIES and ADDITIONAL_FILES
SETUP_EXAMPLE(${TARGETNAME})


More information about the CMake mailing list