How to let some file to be visiable in QtCreator - cmake

I'm using cmake to configure my project. It seems QtCreator only show those files referred by add_executable, add_library and configure_file. Other files in project directory are not visiable in the Projects panel.
Although we can still visit those files by file->open, it make me feel bad that many important source files are not visiable in the Projects panel. So...
How does QtCreator decide whether to show a file?
Is there any cmake command that can make arbitrary file to be visiable in QtCreator?
=======================
Some additional info:
My project is a C++ library with PerlXS interface. XS code is preprocessed into C code by xsubpp, and this action is added into cmake project via add_custom_target. However, the XS file is not added into Porjects panel by QtCreator. Besides, a project can have non-source text files such as README, Changes, etc..

I see no reason to put something specific with project, when you can switch to "File System" browser in QtCreator.
But anyway, the answer still the same. If you wish to see something in project - add it to add_executable, add_library.
For example
set(DATA_FILE ${PROJECT_SOURCE_DIR}/build/README.txt)
...
add_executable(${TARGET_NAME} ${SRC_FILES} ${GLB_HDR_FILES} ${DATA_FILE})
And now we can see README.txt in project
Same trick can be done for other files. Just add them to DATA_FILE variable.

Related

cmake v2.8.19.2 include folder from outside project

I am trying to build a library using cmake version 2.8.10.2
A header is included from a directory outside of the project, I’ve tried adding the path to the directory using:
add_subdirectory($ENV{PRJ2}/path/)
I’ve check the path is correct but when building I get:
fatal error: header_name.h: No such file or directory
It’s driving me crazy…
add_subdirectory adds a folder to the cmake project, searching for the CMakeLists.txt file in it and loading the configuration. If you want to add headers from a directory to a project you should use include_directories (link here)
Consider that using a directory out of the main folder of the project is not convenient. I suggest you two possibilities:
If you are using some headers that are not part of another project (for example you developed by yourself for other reasons and want to add them to your project), then move them inside one of your project folders
If the headers are from another library/project add them using the find_package system. I was not able to find a good guide for the 2.x versions of cmake, but I strongly suggest you to move to 3.x

Cannot get CMake to handle Fortran-90 modules properly

I've had a miserable afternoon trying to add a Fortran-90 module to a large multilanguage library set (mostly C++) built with CMake, and am at the point where I am clearly going in circles. There is an amazing dearth of information online that might help me with this, and the CMake documentation is as inscrutable as always.
The library set is too large to boil down properly (so I've been unable to get a good small reproducer) but the essence of is this. Each library lives in its own directory, with a test directory beneath it. I've added an F90 file containing a module to one of the directories, which I'll call low_library. The contents of this directory are something like:
low_library:
CMakeList.txt
file1.cc
file1.hh
file2.cc
file2.hh
my_module.f90
test:
CMakeList.txt
test1.cc
test2.cc
test3.cc
my_module_test.f90
except many more .cc and .hh files. In the CMakeList.txt file for the library directory, I have instructions that include
add_library(low_library STATIC "")
target_sources(low_library
PUBLIC:
file1.hh
file2.hh
PRIVATE:
file1.cc
file2.cc
)
There's more but it's not obviously relevant.
So the first question is where to put my_module.f90. I want my_module.f90.o to be included in the liblow_library.a file but I need the my_module.mod file to be visible to other libraries I'm building (and to users of the library set). So I add the line
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/fortran_modules)
towards the top of my CMakeList.txt file, add my_module.f90 to the PRIVATE part of the target_sources() PUBLIC list, and ... sigh ... the build system puts the .mod file in the build directory, and not in ${CMAKE_INSTALL_PREFIX}/fortran_modules. The other libraries can't see it and fail to build.
So now I put my_module.f90 in the PUBLIC part of target_sources() and try again. This time the module files goes where I expected it, my test directory can see it and builds successfully, and I'm happy until I move on to building the next library, in directory high_library which depends on low_library. The build comes up with the truly bizarre error:
f951: Fatal Error: Can't rename module file â/scratch/kgbudge/develop/install/fortran_modules/cta_mesh_generator.mod0â to â/scratch/kgbudge/develop/install/fortran_modules/cta_mesh_generator.modâ: No such file or directory
Looking at the rest of the trace, it appears that with my_module.g90 in the public interface of low_library, the build for high_library ignores what's already in my ${CMAKE_INSTALL_PREFIX}/fortran_modules and builds its own copy of the d-mned .mod file in ${CMAKE_INSTALL_PREFIX}/fortran_modules. Which, since we have high-powered build servers and always build in parallel (make -j16 is typical) means a race condition between competing build jobs.
Okay, I know. I needed to include the line
target_include_directories(low_library PUBLIC ${CMAKE_INSTALL_PREFIX}/fortran_modules)
near start of the CMakeLists.txt file for high_library so it knows where to find the modules and wont' try to build its own. Except this doesn't help.
I can find nothing online that gives me any clues what is going on or how to resolve it.
It looks like the problem is that I had my
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/fortran_modules)
only in the libraries that produced or consumed the new modules. But other libraries used the library containing the module and needed to see a copy of the module even though they weren't actually using the module. I think.
Anyway, moving this line into the root CMakeLists.txt allows me to build the whole library successfully. I still seem some warnings:
f951: Warning: Nonexistent include directory â/srcâ [-Wmissing-include-dirs]
but at least it all builds.

Eclipse - Java project's .bin ignored in running plug-in

My project can't seem to find the compiled java classes in the bin folder, although they are all there. This affects the basic editor functionalities, like code completion and code navigation etc.
I have several folders containing .java files and add them as sources through "Use as Source Folder" to the project source. They are compiled and added to the project's bin folder. If I go to the menu Project/Properties/Java Build Path/Source tab, all the source folders that were added appear and the default output folder is set to MyProject/bin so I don't see where the problem lies...
I managed to get it working by adding the bin folder through "Add External Class Folder" to the Libraries and then giving MyProject as "Source Attachment" (for the navigation).
This is more than ugly so I was wondering where the problem could lie...

How to load cmake script with more than one project with Qt Creator

I have a CMake project, and until now, I was using Visual C++ for developing.
Using CMake-gui to generate a solution for VC++, it generates more than one project in the same solution.
But when the script is loaded in qt-creator, only one project is defined, with all the code and folder tree inside, so I can not compile it (or I don't know how to do it).
How can I load the cmake file to load all the projects?
More info:
The first CMakeList.txt has some common configuration. Then, with 'add_subdirectory' function, I add a project to make a library, and another project to make a sample application to use this library.
You should add multiple projects to the root cmake file with help of "add_subdirectory()". Then in Qt Creator you should open the root cmake file. After that you could choose which project to run in the select a kit for running (3) or debugging (4) application pane (check the link).
It sad that you can't (or I don't know how) build only one project. You have to build all projects are added to the root cmake file and then choose which one of them you want to run.
I use Qt Creator 4.0 .
Here is the offical doc http://qt-project.org/doc/qtcreator-2.8/creator-project-cmake.html
My project have a similar structure, just open the top-most CMakeLists.txt file of the project, and qtcreator will import your project.

Cannot find output .a of Cocoa Static Library (in xcode 4)

I have a project with two targets, one is a Cocoa Static Library, the other is the accompanying test project. Despite building the main project in different ways over and over again, I cannot find the .a file that I expect it to produce.
In fact, I cannot find the build folder associated with the project. I need to link to the library in an app, but cannot do so if I can't find the file to link to.
These properties are correctly set:
(Build Products Path) SYMROOT = build
(Intermediate Build Files Path) OBJROOT = $(SYMROOT)
All tests pass (which means the code MUST be building right?)
Breaking the code causes the build to break - again suggesting that it is building.
Also, the "Products > libproject.a" file is red in the xcode project navigation
I also checked the DerivedData directory, but all the seems to get created is the objects fot the OCunit stuff. Still no .a file against which I can link.
Where is my .a file?
Any help would be much appreciated.
It's probably in ~/Library/Developer/Xcode/DerivedData/ somewhere.