I had a project that source code including non-class file in package(eg:.sql,.ftl). I want to generate output including them but the artifacts always contains class file. How can I include them?
It's a web application, and below is source structure(java code part):
src
|
main
|
java
|
package1
|
Class1.java
Class2.java
sql1.sql
sql2.sql
template1.ftl
The output only contains compiled class.
I found a solution:
Project Structure->Module:at the bottom, Exclude files:*.java
Project Structure->Artifacts:Output Layout:add 'java' directory contents to classes
Related
How to exclude a single file from module output? I have seen the field "excluded files" in the module configuration (File -> Project structure -> modules) and tried to enter a pattern like that one:
path\to\file\*Server*
in order to exclude the class
path.to.file.MyServer
but it doesn't work
You should go to Settings | Build, Execution, Deployment | Compiler | Excludes and add your file name to the list.
I built a C++ project which the file structure as same as the image
Every Cpp file is an isolated executable file. And I would like to build a project filter as same as the file structure via CMake.
The following code sample shows the root CMakeLists.txt I wrote for this purpose:
project(Samples)
source_group( "Samples\\ClientSamples" FILES ${PROJECT_SOURCE_DIR}/ClientSamples/ClientSamplesMain.cpp )
source_group( "Samples\\GenericSamples" FILES ${PROJECT_SOURCE_DIR}/GenericSamples/GenericSamplesMain.cpp )
source_group( "Samples\\ServerSamples" FILES ${PROJECT_SOURCE_DIR}/ServerSamples/ServerSamplesDemo.cpp ${PROJECT_SOURCE_DIR}/ServerSamples/HttpServerSample.cpp )
add_subdirectory(GenericSamples)
add_subdirectory(ServerSamples)
add_subdirectory(ClientSamples)
And the result didn't match my expectation.
The result is
.
So, is there a way to reach the goal?
Best Regards.
I am trying to migrate a project from a custom build script to cmake. The source structure looks roughly like this:
src
|
+-CMakeLists.txt
|
+-generated
| |
| +-CMakeLists.txt
| |
| +-database
| |
| +-...
|
+-main
|
+-CMakeLists.txt
|
+-database
|
+-...
The source files in generated/database get autogenerated. cmake seems to be capable of this (that's not part of the question), but I wonder how I can make it build stuff in the right order. main/database contains the framework that is used in the autogenerated files. However, there are other folders in main that depend on the generated sources. If I structure the top-level CMakeLists.txt like this:
add_subdirectory("generated")
add_subdirectory("main")
I cannot refer to main/database in generated/CMakeLists.txt as dependency.
Overall, I have the impression that cmake forces me to structure my files according to their dependencies, but I want to preserve the current layout - the dependencies in the project are far too complex to map them onto a file system hierarchy.
Should I just avoid add_subdirectory and write everything in the top-level CMakeLists.txt? It seems like this should be possible. Or is there another way to solve this?
Overall, I have the impression that cmake forces me to structure
my files according to their dependencies
If CMake has information that target A depends on target B (for example
target_link_libraries(A B)) B will be build first, then A.
If you use generated sources CMake can't get dependency information
and you need to provide it using add_dependencies.
From documentation:
Adding dependencies with this command can be used to make sure one target
is built before another target.
I have the following directory structure.
A
|---B
| |---C
| |---D
|
|
|---E
| |---F
| |---G
I have A directory under which I have B and E. In B, I have C and D files and in E I have F and G files.
I am working on G file and I need to import D file. How do I do that ? If I directly write import "G.h" its throwing error as it will search in E folder. If I use import , its throwing error. Please let me know how to traverse directories in Xcode. I am using latest version of XCode (Xcode 4.6). Thanks!
If you have added the files to the project correctly you should simply be able to write
#import "G.h"
as the physical location should not be an issue. Xcode should be keeping track of those.
Try removing and re-adding the files in question.
You could add "B" to the "Header Search Paths" directly in the Project or Target Build Settings.
Add "${SRCROOT}" to HEADER_SEARCH_PATHS to include your source directory. In your Example it points to A.
If you set it to recursive it will check all subfolders (including B).
With "${SRCROOT}/B" you would only include the header files in folder B.
The quotes are needed, if you have blank space in the path.
But you should not need to do that, if the desired file (G.h) is in you xcode-project.
Try re-adding the file as suggested by Mundi.
Apple Developer Documentation: SRCROOT
Using CMake I am using a third party library, TinyThread++, it is a simple Thread library wrapper and only contains 1 source files and 2 header files.
In my project CMakeList.txt I added the following line:
add_library(TinyThread STATIC ${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/TinyThread/source/tinythread.cpp)
And then added a dependency to this library to the my executable this is working great.
I am trying to figure out how to copy or export the two header files to a common include directory I am using in my project.
${CMAKE_CURRENT_SOURCE_DIR}/../../include
What is the recommended way to do this?
If you simply want to "use" those headerfiles while compiling, you can use include_directories() like Naszta explains.
In case you really want to copy the files, you can use configure_file() or file( COPY ... ) (check the bottom of the section on the file() command).
I think you should do something like this:
SET(TINY_THREAD_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "TinyThread include path")
SET(TINY_THREAD_SOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/tinythread.cpp" CACHE FILEPATH "TinyThread source file")
...
INCLUDE_DIRECTORIES(${TINY_THREAD_INCLUDE_PATH})
ADD_LIBRARY(TinyThread STATIC ${TINY_THREAD_SOURCE_FILE})
This way you could reuse them later by their name. If you would like to hide them in normal mode:
MARK_AS_ADVANCED(TINY_THREAD_INCLUDE_PATH TINY_THREAD_SOURCE_FILE)